【问题标题】:Spring WS - JaxRPC - Web service responseSpring WS - JaxRPC - Web 服务响应
【发布时间】:2012-06-01 09:22:53
【问题描述】:

我正在使用 spring ws jaxrpc 来消费外部 Web 服务。

Web服务的配置如下。

<bean id="myWebService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
        <property name="serviceInterface" value="jatis.avantrade.foundation.model.service.WeatherService"/>
        <property name="wsdlDocumentUrl" value="http://www.w3schools.com/webservices/tempconvert.asmx?WSDL"/>
        <property name="namespaceUri" value="http://tempuri.org/"/>
        <property name="serviceName" value="TempConvert"/>
        <property name="portName" value="TempConvertHttpPost"/>
        <property name="endpointAddress" value="http://www.w3schools.com/webservices/tempconvert.asmx"/>
</bean>



<bean id="client" class="jatis.avantrade.foundation.model.service.WeatherServiceImpl">    
    <property name="service" ref="myWebService"/>
</bean>

然后,我如下调用网络服务。

package jatis.avantrade.foundation.model.service;

import java.rmi.Remote;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.BindingType;

@WebService(serviceName = "TempConvert")
@SOAPBinding(style = Style.DOCUMENT)
@BindingType(value = "http://schemas.xmlsoap.org/wsdl/soap/http")
public interface WeatherService extends Remote {

@WebMethod(action = "http://tempuri.org/CelsiusToFahrenheit", operationName = "CelsiusToFahrenheit")
    public String CelsiusToFahrenheit(String input);
}

但是,它会抛出异常。

Caused by: com.sun.xml.internal.ws.streaming.XMLStreamReaderException: unexpected XML tag. expected: {http://service.model.foundation.avantrade.jatis/}CelsiusToFahrenheitResponse but found: {http://tempuri.org/}CelsiusToFahrenheitResponse
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.verifyTag(XMLStreamReaderUtil.java:203)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.verifyTag(XMLStreamReaderUtil.java:211)
at com.sun.xml.internal.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:513)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:110)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy23.CelsiusToFahrenheit(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.doInvoke(JaxWsPortClientInterceptor.java:520)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.doInvoke(JaxWsPortClientInterceptor.java:494)

【问题讨论】:

    标签: spring jax-rpc


    【解决方案1】:

    尝试从 bean 定义中删除除 serviceInterfaceendpointAddressserviceName 之外的所有属性。

    这应该可以工作并且足以使用您生成的带有wsdl2java 或类似接口的网络服务。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多