2

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>

次に、以下のように Web サービスを呼び出します。

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)
4

1 に答える 1

0

serviceInterfaceendpointAddress、およびを除くすべてのプロパティをserviceNameBean 定義から削除してみてください。

これは機能し、インターフェイスを生成した Web サービスwsdl2javaまたは類似の Web サービスを使用するのに十分なはずです。

于 2012-06-14T02:04:57.527 に答える