简体   繁体   English

代码签名和编写步骤 public static void main(String args[] )

[英]Code signature and steps to write public static void main(String args[] )

Using WSDL2Java the "WeatherService" WSDL to Client side code is generated successfully.使用WSDL2Java成功生成客户端代码的“WeatherService”WSDL。

In which java file and methods should be used for the main class be written to access the and execute the process?在java文件和方法中应该写入主class来访问和执行进程?

  • WeatherServiceCallbackHandler.java

  • WeatherServiceStub.java

I presume ther should be some standard signature code steps to follow and access the methods avaliable in the WSDL.我认为应该遵循一些标准的签名代码步骤并访问 WSDL 中可用的方法。

In neither.两者都没有。 You shouldn't touch the generated code at all.您根本不应该触摸生成的代码。 You class should make calls to the generated code in order to interact with the web-service.您 class 应该调用生成的代码以便与 Web 服务交互。

Normally you would instantiate a service locator and use it to get a stub implementation.通常你会实例化一个服务定位器并使用它来获得一个存根实现。 You could then use the stub directly.然后,您可以直接使用存根。

So in short, your main method should be inside a separate class altogether.所以简而言之,你的主要方法应该完全在一个单独的 class 内。

See code below for how to use the stub implementation generated by wsdl2java:请参阅下面的代码,了解如何使用 wsdl2java 生成的存根实现:

package com.axis.weather;

import static com.axis.weather.WeatherServiceStub.*;

public class Main {
    public static void main(String[] args) {
        Weather w = new Weather();
        w.setHowMuchRain(2.2f);

        SetWeather wrapper = new SetWeather();
        wrapper.setArgs0(w);

        try {
            WeatherServiceStub stub = new WeatherServiceStub(); // will use http://localhost:8080/axis2/services/WeatherService.WeatherServiceHttpSoap12Endpoint/
            stub.setWeather(wrapper);
        } catch (java.rmi.RemoteException re) {
            re.printStackTrace();
        }
    }
}

Regards问候
Yusuf优素福

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在没有 public static void main(String[] args) 的情况下编写 Java 代码? - Is it possible to write Java code without public static void main(String[] args)? 了解公共静态void main(String [] args) - Understanding public static void main(String[] args) 公共void main(String [] args)是无效的Java main方法签名吗? - Is public void main(String[] args) Invalid java main method signature ? 对main方法的误解/“ public static void main(String [] args)”的观点 - Misunderstanding main method/the point of “public static void main(String[] args)” public static void main(String args[]) 为什么 string args[] 是强制性的,为什么我们不使用 public static void main(Object args[])? - public static void main(String args[]) why string args[] is compulsory ,why we not use public static void main(Object args[])? 需要添加“ public static void main(String [] args)”, - Need to add a “public static void main(String[] args)”, 使用 int 而不是 String:public static void main (int[] args) - Using int Instead Of String: public static void main (int[] args) public static void main(String[] args) 抛出异常 - public static void main(String[] args) throws Exception 如何在不使用 public static void main (String[]args) 的情况下在 vs 代码中获取 Java 程序中的用户输入 - How to get user input in java programs in vs code without using public static void main (String[]args) 是否所有要在 java 程序中运行的代码都需要公开 static void main(String[] args)? - Does all code to be run in a java program need to be in public static void main(String[] args)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM