Glen,
Thanks again for the suggestions. Please do not take the following the
wrong way. I'm just venting my frustration over the lack of support for CXF
and this is not directed at you personally.
I really need advice on the role CXF is playing in causing this problem, if
any, not advice on the choice of my IDE and development environment. In
any event I don't see how using Maven helps solve this problem!
What I need to know is where the problem lies, on the client side or on the
server side? I suspect it is on the server side since making the call from
the Eclipse utility and from my client Java app result in the same error!
If that is the case what I'm looking for is an explanation of why the server
side is thinking I'm providing a fully qualified element for the operation
argument. I can see the SOAP message I send to make the call when I use the
Eclipse utility. It appears to be correct to me. I need someone to tell my
whay this SOAP message might be causing the unmarshalling error I'm getting.
For Glen and anyone else that may have been following this, the SOAP message
is provided below.
-<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://soaphttp.rd.nsrr.swim.faa.gov/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-<soapenv:Body>
-<q0:GetTemperature>
<q0:zip>08405</q0:zip>
</q0:GetTemperature>
</soapenv:Body>
</soapenv:Envelope>
As you can see from the SOAP message the argument is qualified with the
prefix q0.
What does the server side not like this?
Thanks,
Mike
-----Original Message-----
From: Glen Mazza [mailto:[email protected]]
Sent: Saturday, October 22, 2011 9:23 PM
To: [email protected]
Subject: Re: Unmarshalling Error
Here's my Java-first tutorial:
http://www.jroller.com/gmazza/entry/java_first_web_service; you may want to
see if you can at least get that to work and then try to extrapolate why
your own web service is not working. Yes, the problem may be with the
"elementFormDefault" parameter but I'm unsure.
I'd recommend using Maven to create and build your web service. Eclipse is
fine for coding after the artifacts have been generated IMO, but not for the
original generation of the web service or the building/compilation of it.
Cutesy IDE plugins usually create more problems than they solve.
Regards,
Glen
On 10/22/2011 02:51 PM, Michael wrote:
Thank you for the quick reply Glen.
I developed both the service and the client code. The service is a
Java first service. We generated a WSDL from our Java code using the
Eclipse plugin for CXF. We needed to make some changes to the WSDL to
support the abstract\concrete approach to providing a web service
contract. We also use a separate schema file for all message content
(e.g. the zip that is a parameter to the operation that is failing).
I created another project in Eclipse to develop a Java client. I used
the WSDL described above to generate the Java code. Once again I used
the CXF Eclipse plugin.
I am using CXF v2.4.0 here at home and v2.3.1 at work. Both provide
the some error.
Both myself and someone working on this with me suspect some problem
with the WSDL, as you indicated. I'm thinking something along the
lines of a problem with the elements defined in the schema and the
elementFormDefault="qualified" parameter. I'm also thinking that
maybe there is some difference in the WSDL and the annotations in the
Java code for the interface.
I'm going to include below both the WSDL schema file and the annotated
Java code for the interface (SEI). If you see anything please let us
know. In the mean time we will be looking at your other recommendations
as well.
Thanks again.
<?xml version="1.0" encoding="utf-8"?> <xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://soaphttp.rd.nsrr.swim.faa.gov/"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://soaphttp.rd.nsrr.swim.faa.gov/">
<xsd:complexType name="SetTemperature">
<xsd:sequence>
<xsd:element name="zip" type="xsd:int"/>
<xsd:element name="temp" type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SetTemperatureResponse">
<xsd:sequence/>
</xsd:complexType>
<xsd:complexType name="GetTemperature">
<xsd:sequence>
<xsd:element name="zip" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GetTemperatureResponse">
<xsd:sequence>
<xsd:element name="return" type="xsd:float"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GetForecast">
<xsd:sequence>
<xsd:element minOccurs="0" name="loc" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GetForecastResponse">
<xsd:sequence>
<xsd:element minOccurs="0" name="return" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="SetTemperature" type="tns:SetTemperature"/>
<xsd:element name="SetTemperatureResponse"
type="tns:SetTemperatureResponse"/>
<xsd:element name="GetTemperature" type="tns:GetTemperature"/>
<xsd:element name="GetTemperatureResponse"
type="tns:GetTemperatureResponse"/>
<xsd:element name="GetForecast" type="tns:GetForecast"/>
<xsd:element name="GetForecastResponse"
type="tns:GetForecastResponse"/> </xsd:schema>
/**
* ISoapHttpWeather interface
*
* @author Ashley Le
* @date 07.11.2011
*/
package gov.faa.swim.nsrr.rd.soaphttp;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
@WebService(name = "ISoapHttpWeather", targetNamespace =
"http://soaphttp.rd.nsrr.swim.faa.gov/")
public interface ISoapHttpWeather
{
@WebMethod(operationName = "GetForecast", action =
"urn:GetForecast")
@RequestWrapper(className =
"gov.faa.swim.nsrr.rd.soaphttp.jaxws.GetForecast", localName =
"GetForecast", targetNamespace = "http://soaphttp.rd.nsrr.swim.faa.gov/")
@ResponseWrapper(className =
"gov.faa.swim.nsrr.rd.soaphttp.jaxws.GetForecastResponse", localName =
"GetForecastResponse", targetNamespace =
"http://soaphttp.rd.nsrr.swim.faa.gov/")
public String GetForecast(@WebParam(name = "arg0") String loc);
@WebMethod(operationName = "GetTemperature", action =
"urn:GetTemperature")
@RequestWrapper(className =
"gov.faa.swim.nsrr.rd.soaphttp.jaxws.GetTemperature", localName =
"GetTemperature", targetNamespace =
"http://soaphttp.rd.nsrr.swim.faa.gov/")
@ResponseWrapper(className =
"gov.faa.swim.nsrr.rd.soaphttp.jaxws.GetTemperatureResponse",
localName = "GetTemperatureResponse", targetNamespace =
"http://soaphttp.rd.nsrr.swim.faa.gov/")
public float GetTemperature(@WebParam(name = "arg0") int zip);
@WebMethod(operationName = "SetTemperature", action =
"urn:SetTemperature")
@RequestWrapper(className =
"gov.faa.swim.nsrr.rd.soaphttp.jaxws.SetTemperature", localName =
"SetTemperature", targetNamespace =
"http://soaphttp.rd.nsrr.swim.faa.gov/")
@ResponseWrapper(className =
"gov.faa.swim.nsrr.rd.soaphttp.jaxws.SetTemperatureResponse",
localName = "SetTemperatureResponse", targetNamespace =
"http://soaphttp.rd.nsrr.swim.faa.gov/")
public void SetTemperature(@WebParam(name = "arg0") int zip,
@WebParam(name = "arg1") float temp); }
-----Original Message-----
From: Glen Mazza [mailto:[email protected]]
Sent: Saturday, October 22, 2011 8:27 AM
To: [email protected]
Subject: Re: Unmarshalling Error
What framework are you using for your SOAP client? Do you know the
version of CXF used for the web service provider?
From here:
Unmarshalling Error: unexpected element
(uri:"http://soaphttp.rd.nsrr.swim.faa.gov/", local:"zip"). Expected
elements are<{}zip>
The WSDL from which you generated your SOAP client is expecting a "zip"
element with no namespace but is getting a zip element with the
namespace listed above. It might be good to confirm that with
Wireshark[1].
My guess, if not a library/JAR problem, is that something is wrong
with the WSDL.
You can check this by modifying the local copy of your WSDL to have it
not send the namespace as requested, and generate your client[2] from
that WSDL, and see what happens.
HTH,
Glen
[1] http://www.jroller.com/gmazza/entry/soap_calls_over_wireshark
[2] http://www.jroller.com/gmazza/entry/soap_client_tutorial
On 10/22/2011 07:24 AM, Michael wrote:
I am getting an unmarshalling error when my client attempts to call a
CXF web service operation. I will provide below both the error
received on the client side and the error and a portion of the stack
trace from the server side.
Client Side Error
Oct 22, 2011 6:46:47 AM com.sun.xml.internal.ws.model.RuntimeModeler
getRequestWrapperClass
INFO: Dynamically creating request wrapper Class
gov.faa.swim.nsrr.rd.soaphttp.GetTemperature
Oct 22, 2011 6:46:47 AM com.sun.xml.internal.ws.model.RuntimeModeler
getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class
gov.faa.swim.nsrr.rd.soaphttp.GetTemperatureResponse
Oct 22, 2011 6:46:47 AM com.sun.xml.internal.ws.model.RuntimeModeler
getRequestWrapperClass
INFO: Dynamically creating request wrapper Class
gov.faa.swim.nsrr.rd.soaphttp.SetTemperature
Oct 22, 2011 6:46:47 AM com.sun.xml.internal.ws.model.RuntimeModeler
getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class
gov.faa.swim.nsrr.rd.soaphttp.SetTemperatureResponse
Oct 22, 2011 6:46:47 AM com.sun.xml.internal.ws.model.RuntimeModeler
getRequestWrapperClass
INFO: Dynamically creating request wrapper Class
gov.faa.swim.nsrr.rd.soaphttp.GetForecast
Oct 22, 2011 6:46:47 AM com.sun.xml.internal.ws.model.RuntimeModeler
getResponseWrapperClass
INFO: Dynamically creating response wrapper bean Class
gov.faa.swim.nsrr.rd.soaphttp.GetForecastResponse
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException:
Unmarshalling Error: unexpected element
(uri:"http://soaphttp.rd.nsrr.swim.faa.gov/", local:"zip"). Expected
elements are<{}zip>
at
com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknow
n
Source)
at
com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknow
n
Source)
at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown
Source)
at
com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown
Source)
at
com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown
Source)
at $Proxy23.getTemperature(Unknown Source)
at
gov.faa.swim.nsrr.rd.soaphttp.SoapHttpWeatherCanonicalClientApp.main(
S
oapHtt
pWeatherCanonicalClientApp.java:13)
Server Side Error (and partial stack trace)
06:46:47,495 INFO [STDOUT] DefaultValidationEventHandler: [ERROR]:
unexpected element (uri:"http://soaphttp.rd.nsrr.swim.faa.gov/",
local:"zip"). Expected elements are<{}zip>
06:46:47,495 INFO [STDOUT] Location: line 1
06:46:47,511 WARN [org.apache.cxf.phase.PhaseInterceptorChain]
Interceptor
for{http://soaphttp.rd.nsrr.swim.faa.gov/}SoapHttpWeatherImpl#{http:/
/ soapht tp.rd.nsrr.swim.faa.gov/}GetTemperature has thrown
exception,
unwinding now:
org.apache.cxf.interceptor.Fault:
Unmarshalling Error: unexpected element
(uri:"http://soaphttp.rd.nsrr.swim.faa.gov/", local:"zip").
Expected elements
are<{}zip>
at
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.
j
ava:78
7) [:2.3.1]
at
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.
j
ava:62
8) [:2.3.1]
at
org.apache.cxf.jaxb.io.DataReaderImpl.read(DataReaderImpl.java:133)
[:2.3.1]
at
org.apache.cxf.interceptor.DocLiteralInInterceptor.handleMessage(DocL
i
teralI
nInterceptor.java:109) [:2.3.1]
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercept
o
rChain
.java:255) [:2.3.1]
at
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainIniti
a
tionOb
server.java:113) [:2.3.1]
at
org.apache.cxf.transport.servlet.ServletDestination.invoke(ServletDes
t
inatio
n.java:97) [:2.3.1]
at
org.apache.cxf.transport.servlet.ServletController.invokeDestination(
S
ervlet
Controller.java:461) [:2.3.1]
at
org.jboss.wsf.stack.cxf.ServletControllerExt.invoke(ServletController
E
xt.jav
a:172) [:3.4.1.GA]
at
org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestH
a
ndlerI
mpl.java:57) [:3.4.1.GA]
at
org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(Se
r
vletHe
lper.java:156) [:3.4.1.GA]
at
org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:90)
[:3.4.1.GA]
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(Ab
s
tractH
TTPServlet.java:179) [:2.3.1]
at
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractH
T
TPServ
let.java:103) [:2.3.1]
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
[:1.0.0.Final]
The client side error messages shown above are from executing a small
Java client I coded. When I use the Web Service utility in Eclipse
to try to call the same operation I get the same error.
I can provide my WSDL and both the annotated server and client side
Java code if needed.
Thanks,
Mike
--
Glen Mazza
Talend - http://www.talend.com/apache
Blog - http://www.jroller.com/gmazza
Twitter - glenmazza
--
Glen Mazza
Talend - http://www.talend.com/apache
Blog - http://www.jroller.com/gmazza
Twitter - glenmazza