consuming soap web services in a java spring app -
ok, there third party soap web services need use in java spring app.
i have address , wsdl. service works fine in soapui.
to have working in spring java client, got inspiration spring tutorial https://spring.io/guides/gs/consuming-web-service/ tutorial works fine weather service.
however, if use tutorial wsdl, generating classes, adding xxxclient , xxxconfiguration class, compiles fine fails when soap service called.
caused by: org.springframework.ws.soap.client.soapfaultclientexception: message action 'https://xxx/services/formssignin' cannot processed @ receiver, due contractfilter mismatch @ endpointdispatcher. may because of either contract mismatch (mismatched actions between sender , receiver) or binding/security mismatch between sender , receiver. check sender , receiver have same contract , same binding (including security requirements, e.g. message, transport, none). @ org.springframework.ws.soap.client.core.soapfaultmessageresolver.resolvefault(soapfaultmessageresolver.java:38) ~[spring-ws-core-2.2.3.release.jar:2.2.3.release]
in weatherclient class tutorial, code follow.
public getcityforecastbyzipresponse getcityforecastbyzip(string zipcode) { getcityforecastbyzip request = new getcityforecastbyzip(); request.setzip(zipcode); log.info("requesting forecast " + zipcode); getcityforecastbyzipresponse response = (getcityforecastbyzipresponse) getwebservicetemplate() .marshalsendandreceive( "http://wsf.cdyne.com/weatherws/weather.asmx", request, new soapactioncallback("http://ws.cdyne.com/weatherws/getcityforecastbyzip")); return response; }
in case, don't know ".asmx" extension. in soapui, can see endpoint ends ".svc" used @ same location (maybe wcf).
public string getsessiontoken() { formssignin request = new formssignin(); objectfactory factory = new objectfactory(); request.setusername(factory.createformssigninusername(appuser_username)); request.setpassword(factory.createformssigninpassword(appuser_password)); request.setforcesignin(true); formssigninresponse response = (formssigninresponse) getwebservicetemplate() .marshalsendandreceive( "https://xxx/services/svcappuser.svc", request, new soapactioncallback( "https://xxxx/services/formssignin" )); string sessionid = response.getformssigninresult().getvalue(); system.out.println("sessionid="+sessionid); return sessionid; }
anyway, doesn't seem work in spring app. idea?
Comments
Post a Comment