Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Wizard generated WSDL based client does not include namespace in the Method definitions(JAXWS/Videos "Deploy a Service to Tomcat" Describes how to create a client from WSDL. This client does not match the server created methods because the namespace is missing in the client met)
Wizard generated WSDL based client does not include namespace in the Method definitions [message #719748] Sun, 28 August 2011 18:45 Go to next message
Patrick Sofin is currently offline Patrick SofinFriend
Messages: 2
Registered: August 2011
Junior Member
Greetings all:

["//" was removed in all instances from "http" in this message so that links would be disabled.]

I am attempting to build sample code for JAXWS using Apache CXF 2.4.2 Web Tools version 3.0 on Windows 7 Ultimate with Java SDK v1.7 and Apache Tomcat v7.0 in the Eclipse Indigo IDE V3.7.

I am loosely following the JAXWS Video sample "Deploy a service to Tomcat" which is somewhat out of date.

I am able to successfully create a Java Beans bottom up server instance using these instructions, and I can deploy this service to Tomcat 7.0 and see the service in my browser window, and attached to the Tomcat server in my "servers" window.

Available SOAP services:
Converter_WSDL2
celsiusToFarenheit
farenheitToCelsius
Endpoint address: http:localhost:8080/Converter_WSDL2/services/Converter_WSDL2Port
WSDL : {http:example.iona.com/}Converter_WSDL2Service
Target namespace: http:example.iona.com/


Available RESTful services:



The XML schema follows (seems fine to me):

<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:xs="http:www.w3.org/2001/XMLSchema" xmlns:tns="http:example.iona.com/" elementFormDefault="unqualified" targetNamespace="http:example.iona.com/" version="1.0">
<xs:element name="celsiusToFarenheit" type="tns:celsiusToFarenheit"/>
<xs:element name="celsiusToFarenheitResponse" type="tns:celsiusToFarenheitResponse"/>
<xs:element name="farenheitToCelsius" type="tns:farenheitToCelsius"/>
<xs:element name="farenheitToCelsiusResponse" type="tns:farenheitToCelsiusResponse"/>
<xs:complexType name="celsiusToFarenheit">
<xs:sequence>
<xs:element name="arg0" type="xs:float"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="celsiusToFarenheitResponse">
<xs:sequence>
<xs:element name="return" type="xs:float"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="farenheitToCelsius">
<xs:sequence>
<xs:element name="arg0" type="xs:float"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="farenheitToCelsiusResponse">
<xs:sequence>
<xs:element name="return" type="xs:float"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

The WSDL is here (seems fine to me):

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="Converter_WSDL2Service" targetNamespace="http:example.iona.com/" xmlns:wsdl="http:schemas.xmlsoap.org/wsdl/" xmlns:tns="http:example.iona.com/" xmlns:xsd="http:www.w3.org/2001/XMLSchema" xmlns:soap="http:schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
<schema xmlns="http:www.w3.org/2001/XMLSchema">
<import namespace="http:example.iona.com/" schemaLocation="converter_wsdl2_schema1.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="celsiusToFarenheitResponse">
<wsdl:part name="parameters" element="tns:celsiusToFarenheitResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="farenheitToCelsiusResponse">
<wsdl:part name="parameters" element="tns:farenheitToCelsiusResponse">
</wsdl:part>
</wsdl:message>
<wsdl:message name="farenheitToCelsius">
<wsdl:part name="parameters" element="tns:farenheitToCelsius">
</wsdl:part>
</wsdl:message>
<wsdl:message name="celsiusToFarenheit">
<wsdl:part name="parameters" element="tns:celsiusToFarenheit">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="Converter_WSDL2">
<wsdl:operation name="celsiusToFarenheit">
<wsdl:input name="celsiusToFarenheit" message="tns:celsiusToFarenheit">
</wsdl:input>
<wsdl:output name="celsiusToFarenheitResponse" message="tns:celsiusToFarenheitResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="farenheitToCelsius">
<wsdl:input name="farenheitToCelsius" message="tns:farenheitToCelsius">
</wsdl:input>
<wsdl:output name="farenheitToCelsiusResponse" message="tns:farenheitToCelsiusResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Converter_WSDL2ServiceSoapBinding" type="tns:Converter_WSDL2">
<soap:binding style="document" transport="http:schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="celsiusToFarenheit">
<soap:operation soapAction="urn:CelsiusToFarenheit" style="document"/>
<wsdl:input name="celsiusToFarenheit">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="celsiusToFarenheitResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="farenheitToCelsius">
<soap:operation soapAction="urn:FarenheitToCelsius" style="document"/>
<wsdl:input name="farenheitToCelsius">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="farenheitToCelsiusResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Converter_WSDL2Service">
<wsdl:port name="Converter_WSDL2Port" binding="tns:Converter_WSDL2ServiceSoapBinding">
<soap:address location="http:localhost:8080/Converter_WSDL2/services/Converter_WSDL2Port"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


I have made several attempts to create a successful client using the "Web Service Client" wizard within the Eclipse IDE.

When I attempt to run the client as a Java application I get variations on this error:

Aug 28, 2011 8:16:43 AM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http:example.iona.com/}Converter_WSDL2Service from WSDL: http:localhost:8080/Converter_WSDL2/services/Converter_WSDL2Port?wsdl
Invoking celsiusToFarenheit...
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"http:example.iona.com/", local:"arg0"). Expected elements are <{}arg0>
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
at $Proxy25.celsiusToFarenheit(Unknown Source)
at com.iona.example.client.ConverterWSDL2_ConverterWSDL2Port_Client.main(ConverterWSDL2_ConverterWSDL2Port_Client.java:55)
Caused by: org.apache.cxf.binding.soap.SoapFault: Unmarshalling Error: unexpected element (uri:"http:example.iona.com/", local:"arg0"). Expected elements are <{}arg0>
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:46)
at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:105)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:771)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1600)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1485)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1393)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:640)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:519)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:449)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:352)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:304)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
... 2 more


Research on this issue suggests that the problem may be caused by the fact that the server method and the client method, as created by the WTP Wizards, do not match. The namespace is defined for these arguments in the server method, but not in the client method.

Here is the offending method on the server instance (note the presence of "namespace" on the "@XmlType" label):


package com.iona.example.jaxws;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
* This class was generated by Apache CXF 2.4.2
* Sun Aug 28 07:35:44 MDT 2011
* Generated source version: 2.4.2
*/

@XmlRootElement(name = "celsiusToFarenheit", namespace = "http:example.iona.com/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "celsiusToFarenheit", namespace = "http:example.iona.com/")

public class CelsiusToFarenheit {

@XmlElement(name = "arg0")
private float arg0;

public float getArg0() {
return this.arg0;
}

public void setArg0(float newArg0) {
this.arg0 = newArg0;
}

}



Here is the companion method on the client instance (note the absence of "namespace" on the "@XmlType" label):


package com.iona.example.client;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;


/**
* <p>Java class for celsiusToFarenheit complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="celsiusToFarenheit">
* &lt;complexContent>
* &lt;restriction base="{http:www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="arg0" type="{http:www.w3.org/2001/XMLSchema}float"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "celsiusToFarenheit", propOrder = {
"arg0"
})
public class CelsiusToFarenheit {

protected float arg0;

/**
* Gets the value of the arg0 property.
*
*/
public float getArg0() {
return arg0;
}

/**
* Sets the value of the arg0 property.
*
*/
public void setArg0(float value) {
this.arg0 = value;
}

}



I tried making these changes with no luck:


package com.iona.example.jaxws;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
* This class was generated by Apache CXF 2.4.2
* Sun Aug 28 07:35:44 MDT 2011
* Generated source version: 2.4.2
*/

//@XmlRootElement(name = "celsiusToFarenheit", namespace = "http:example.iona.com/")
@XmlRootElement(name = "celsiusToFarenheit")

@XmlAccessorType(XmlAccessType.FIELD)
//@XmlType(name = "celsiusToFarenheit", namespace = "http:example.iona.com/")
@XmlType(name = "celsiusToFarenheit")


public class CelsiusToFarenheit {

@XmlElement(name = "arg0")
private float arg0;

public float getArg0() {
return this.arg0;
}

public void setArg0(float newArg0) {
this.arg0 = newArg0;
}

}

If I could get the WTP wizard to add the namespace to the client generated code, this problem would probably go away.

I tried changing the Schema value of elementFormDefault from "unqualified" to "qualified", then rebuilding the client using the wizard. No luck here.

Can any one help me with this issue?
Re: Wizard generated WSDL based client does not include namespace in the Method definitions [message #719753 is a reply to message #719748] Sun, 28 August 2011 19:22 Go to previous messageGo to next message
Patrick Sofin is currently offline Patrick SofinFriend
Messages: 2
Registered: August 2011
Junior Member
Greetings again:

["//" is removed from all "http" to disable links in this message.]

I rebuilt the project from scratch (again) and I got a new but similar error:

Aug 28, 2011 12:58:58 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http:example.iona.com/}Converter_WSDLService from WSDL: http:localhost:8080/Converter_WSDL/services/Converter_WSDLPort?wsdl
Invoking celsiusToFarenheit...
Aug 28, 2011 12:58:59 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http:example.iona.com/}Converter_WSDLService#{http:example.iona.com/}celsiusToFarenheit has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"http:example.iona.com/", local:"return"). Expected elements are <{}return>
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:791)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:632)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:771)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1600)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1485)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1393)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:640)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:519)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:449)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:352)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:304)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
at $Proxy25.celsiusToFarenheit(Unknown Source)
at com.iona.example.client.ConverterWSDL_ConverterWSDLPort_Client.main(ConverterWSDL_ConverterWSDLPort_Client.java:55)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[com.sun.istack.SAXParseException2; lineNumber: 1; columnNumber: 151; unexpected element (uri:"http:example.iona.com/", local:"return"). Expected elements are <{}return>]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:768)
... 20 more
Caused by: com.sun.istack.SAXParseException2; lineNumber: 1; columnNumber: 151; unexpected element (uri:"http:example.iona.com/", local:"return"). Expected elements are <{}return>
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:254)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:249)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.childElement(Loader.java:101)
at com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.childElement(StructureLoader.java:243)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:478)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:459)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
... 22 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http:example.iona.com/", local:"return"). Expected elements are <{}return>
... 33 more

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Unmarshalling Error: unexpected element (uri:"http:example.iona.com/", local:"return"). Expected elements are <{}return>
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156)
at $Proxy25.celsiusToFarenheit(Unknown Source)
at com.iona.example.client.ConverterWSDL_ConverterWSDLPort_Client.main(ConverterWSDL_ConverterWSDLPort_Client.java:55)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[com.sun.istack.SAXParseException2; lineNumber: 1; columnNumber: 151; unexpected element (uri:"http:example.iona.com/", local:"return"). Expected elements are <{}return>]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:425)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:768)
at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:632)
at org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:156)
at org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocLiteralInInterceptor.java:109)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:771)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1600)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1485)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1393)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:640)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:519)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:449)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:352)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:304)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:88)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
... 2 more
Caused by: com.sun.istack.SAXParseException2; lineNumber: 1; columnNumber: 151; unexpected element (uri:"http:example.iona.com/", local:"return"). Expected elements are <{}return>
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:642)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:254)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportError(Loader.java:249)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.reportUnexpectedChildElement(Loader.java:116)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.childElement(Loader.java:101)
at com.sun.xml.bind.v2.runtime.unmarshaller.StructureLoader.childElement(StructureLoader.java:243)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext._startElement(UnmarshallingContext.java:478)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.startElement(UnmarshallingContext.java:459)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.handleStartElement(StAXStreamConnector.java:242)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:176)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
... 22 more
Caused by: javax.xml.bind.UnmarshalException: unexpected element (uri:"http:example.iona.com/", local:"return"). Expected elements are <{}return>
... 33 more


I changed the CelsiusToFarenheitResponse class on the server:


package com.iona.example.jaxws;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
* This class was generated by Apache CXF 2.4.2
* Sat Aug 27 22:31:42 MDT 2011
* Generated source version: 2.4.2
*/

@XmlRootElement(name = "celsiusToFarenheitResponse", namespace = "http:example.iona.com/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "celsiusToFarenheitResponse", namespace = "http:example.iona.com/")

public class CelsiusToFarenheitResponse {

//@XmlElement(name = "return", namespace = "http:example.iona.com/")
@XmlElement(name = "return")
private float _return;

public float getReturn() {
return this._return;
}

public void setReturn(float new_return) {
this._return = new_return;
}

}



and the FarenheitToCelsiusResponse class on the server:


package com.iona.example.jaxws;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

/**
* This class was generated by Apache CXF 2.4.2
* Sat Aug 27 22:31:42 MDT 2011
* Generated source version: 2.4.2
*/

@XmlRootElement(name = "farenheitToCelsiusResponse", namespace = "http:example.iona.com/")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "farenheitToCelsiusResponse", namespace = "http:example.iona.com/")

public class FarenheitToCelsiusResponse {

//@XmlElement(name = "return", namespace = "http:example.iona.com/")
@XmlElement(name = "return")
private float _return;

public float getReturn() {
return this._return;
}

public void setReturn(float new_return) {
this._return = new_return;
}

}

I suspect that the original namespace error may have been due to creating a client instance using the elementFormDefault="qualified" change (from "unqualified") in the original XMl Schema.

I restarted the server and I got this output from the client:

Aug 28, 2011 1:08:47 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFO: Creating Service {http:example.iona.com/}Converter_WSDLService from WSDL: http:localhost:8080/Converter_WSDL/services/Converter_WSDLPort?wsdl
Invoking celsiusToFarenheit...
celsiusToFarenheit.result=289.4
Invoking farenheitToCelsius...
farenheitToCelsius.result=22.777779



Clearly, this example is working now.

But why do I have to edit the Wizard generated server code and remove the namespace qualifiers?

How can I use the wizard to generate server and client code that does not need to be modified further to run?

Do I need to stop generating client code using the server WSDL?

namespaces can be very important. What would I do to make this code work and still keep the namespace designations?

Can anyone help me with this problem?
Re: Wizard generated WSDL based client does not include namespace in the Method definitions [message #720578 is a reply to message #719753] Tue, 30 August 2011 21:19 Go to previous messageGo to next message
Shane Clarke is currently offline Shane ClarkeFriend
Messages: 67
Registered: July 2009
Member
Hi Patrick,

The videos on the JAXWS wiki are outdated and in need of an update.

In relation to the code generation issue that you're seeing there have been changes in the CXF response wrapper code generation since those videos were shot.

if you've added the @javax.xml.ws.ResponseWrapper annotation to the web methods in your SEI (or implementation class if not using an SEI).

Add the following @WebResult annotation to your web methods and try regenerating your service:

@javax.jws.WebResult(name = "return", targetNamespace="")

You'll have to do that in the Java Editor or by using the Annotation Properties view. You can't do it in the Web service wizard when using the CXF web service runtime just yet.

Thanks,
Shane
Re: Wizard generated WSDL based client does not include namespace in the Method definitions [message #950003 is a reply to message #719748] Fri, 19 October 2012 14:34 Go to previous messageGo to next message
Mrugendra Deshpande is currently offline Mrugendra DeshpandeFriend
Messages: 1
Registered: October 2012
Junior Member
I has the same issue.
As you correctly pointed in the original message, there is some discrepancy in the server side and the generated client code.

This specific issue can be fixed with providing the namespace to the @XmlElement:

@XmlElement(name = "arg0", namespace = "http:example.iona.com/")

Sincere Regards,
Mrugendra

Re: Wizard generated WSDL based client does not include namespace in the Method definitions [message #1298116 is a reply to message #719748] Wed, 16 April 2014 04:05 Go to previous message
Ramana Rao is currently offline Ramana RaoFriend
Messages: 1
Registered: April 2014
Junior Member
Hi Patrick Sofin,

this is ramana,

Let me complete the discussion about your problem,

While generating the client your problem is raised, because from the service you are returning some value to the client from the your service impl.

While generating Web service you need to handle the return value with the @WebResult annotation. If you are handled the return value with the @WebResult then everything will be executed fine and your client also generated without any problem.

But here, while writing service, you are returning something to the client, but while generating you are not handled the return value, so you are facing the problem while generating the web service client.

See while working with eclipse products, especially with INDIGO, while adding the annotations to the web services like @WebMethod, @WebParam.... bla... bla..., check it once @WebResult annotation is available or not.

I am strictly saying, the @WebResult annotation is not available while adding the annotations to your web service.

Your problem is raised due to the cause of @WebResult annotation is missing.

Please update your INDIGO version or check with the eclipse people how to add the @WebResult annotation to your service while generating the web service.


In Eclipse JUNO, Kepler and Luna version the @WebResult annotation is added while generating the web service.


Thanks & Regards
-----------------
-Ramana

Previous Topic:Cleanup Document
Next Topic:Help required to decide the IDE
Goto Forum:
  


Current Time: Fri Apr 19 09:36:25 GMT 2024

Powered by FUDForum. Page generated in 0.02486 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top