在独立应用程序中调用服务操作时出现JAX WS未知源错误

时间:2013-09-11 11:28:51

标签: java jax-ws

我试图像这样调用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是try块中的这行gmFlagUpdated = myProxy.setGMFlag(gmFlagUpdate);

奇怪的是,我尝试了同一个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;
}

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

0 个答案:

没有答案