2

I am using spring ws jaxrpc to consume external web services.

The configuration for web services is as below.

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

Then, I call the web service as below.

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);
}

But, it throws exception.

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)
tshepang
  • 12,111
  • 21
  • 91
  • 136
Iswanto San
  • 18,263
  • 13
  • 58
  • 79

1 Answers1

0

Try removing all properties except serviceInterface, endpointAddress, and serviceName from the bean definition.

This should work and be enough for using webservices you've generated interfaces with wsdl2java or similar.

Ricardo Pardini
  • 922
  • 7
  • 17