1

我正在尝试像这样调用 jax ws 操作:

MyService myProxy = getProxy();
boolean gmFlagUpdated = false; 
GmFlagUpdate gmFlagUpdate = new GmFlagUpdate();
gmFlagUpdate.setPoint("Point1");
gmFlagUpdate.setMyID("ID1");
gmFlagUpdate.setGMFlag("true");

try { 
gmFlagUpdated = myProxy.setGMFlag(gmFlagUpdate);         
log.info("IsgmFlagUpdated-->"+gmFlagUpdated); 
} catch (OperationFaultException e) {
e.printStackTrace();
} catch (SystemFaultException e) {
e.printStackTrace(); 
}catch(Exception e){
e.printStackTrace();
}

问题是它给了我以下错误:

java.lang.NullPointerException
at $Proxy28.setGMFlag(Unknown Source)
at com.kunal.gm.MyServiceFacade.main(MyServiceFacade.java:84)

行 : 84 是gmFlagUpdated = myProxy.setGMFlag(gmFlagUpdate);try 块内的这一行。

奇怪的是,我已经尝试了同一个 WS 的另一个操作,它给了我一个完美的响应。

我在这里做错了什么吗?还是因为我正在使用的 WSDL 最近可能已更新/更改?

编辑 :

getProxy() 实现:

public static MyService  getProxy() {
    URL url = null;
    try {
    URL baseUrl =  com.kunal.gm.service.MyService_Service.class.getResource("/com/kunal/gm/");
    url = new URL(baseUrl, "file:./MyWSDL.wsdl");
    } catch (MalformedURLException malformedURLException) {
    System.out.println(malformedURLException.toString());
    }

    QName serviceName = new QName("http://com.host.provider/deploy/service","MyService");
    MyService_Service service = new MyService_Service(url, serviceName);
    MyService myPort = service.getPort();
    BindingProvider bp = (BindingProvider) myPort;
    bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,"https://endpoint.com.myWSDL");
    bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,"username");
    bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,"password");
return myPort;
}

非常感谢任何建议/帮助。

4

0 回答 0