Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在JavaSpring应用程序中使用soap web服务_Java_Spring_Web Services_Soap - Fatal编程技术网

在JavaSpring应用程序中使用soap web服务

在JavaSpring应用程序中使用soap web服务,java,spring,web-services,soap,Java,Spring,Web Services,Soap,好的,我需要在我的JavaSpring应用程序中使用第三方SOAPWeb服务 我有地址和WSDL。该服务在SoapUI中运行良好 为了让它在我的SpringJava客户端中工作,我从这个spring教程中得到了灵感 本教程适用于此天气服务 但是,如果我将该教程用于我的wsdl,生成类,然后添加XXXClient和XXXConfiguration类,它可以很好地编译,但在实际调用soap服务时失败 Caused by: org.springframework.ws.soap.client.Soap

好的,我需要在我的JavaSpring应用程序中使用第三方SOAPWeb服务

我有地址和WSDL。该服务在SoapUI中运行良好

为了让它在我的SpringJava客户端中工作,我从这个spring教程中得到了灵感 本教程适用于此天气服务

但是,如果我将该教程用于我的wsdl,生成类,然后添加XXXClient和XXXConfiguration类,它可以很好地编译,但在实际调用soap服务时失败

Caused by: org.springframework.ws.soap.client.SoapFaultClientException: The message with Action 'https://XXX/Services/FormsSignIn' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver.  Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
    at org.springframework.ws.soap.client.core.SoapFaultMessageResolver.resolveFault(SoapFaultMessageResolver.java:38) ~[spring-ws-core-2.2.3.RELEASE.jar:2.2.3.RELEASE]
在教程中的weatherClient类中,代码如下所示

public GetCityForecastByZIPResponse getCityForecastByZip(String zipCode) {
    GetCityForecastByZIP request = new GetCityForecastByZIP();
    request.setZIP(zipCode);
    log.info("Requesting forecast for " + zipCode);
    GetCityForecastByZIPResponse response = (GetCityForecastByZIPResponse) getWebServiceTemplate()
            .marshalSendAndReceive(
                    "http://wsf.cdyne.com/WeatherWS/Weather.asmx",
                    request,
                    new SoapActionCallback("http://ws.cdyne.com/WeatherWS/GetCityForecastByZIP"));
    return response;
}
就我而言,我对“.asmx”扩展名一无所知。在SoapUI中,我可以看到端点以“.svc”结尾,所以我在同一位置使用了它(可能与WCF有关)


无论如何,它在我的spring应用程序中似乎不起作用。有什么想法吗

构造请求对象的方式不正确,请通过ObjectFactory实例来构造它;这没有什么区别:-(SOAPFault主要是由于请求的格式无效。请用XML打印请求,然后尝试使用SOAPUI访问服务。通过这种方式,您可以跟踪问题。
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;
}