You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Ziemer, Tom" <to...@wirecard.com> on 2013/09/26 08:45:43 UTC
CAMEL-SOAP uses wrong namespace
Hi,
I have an existing web-service-client (spring-ws+JAXB) that I want to replace with camel. The XSD needed for this WS uses different namespaces for request/response and fault. While trying to migrate to camel/camel-soap, I encountered the following problem:
Request/Response NS: "foo"
Fault NS: "bar"
Route:
public void configure() throws Exception {
SoapJaxbDataFormat soap = new SoapJaxbDataFormat(Request.class.getPackage().getName());
// soap.setVersion("1.2");
// JaxbDataFormat soap = new JaxbDataFormat(Request.class.getPackage().getName());
from("direct:someService")
.marshal(soap)
.setHeader(SOAP_ACTION, constant("baz"))
.setHeader(Exchange.CONTENT_TYPE, constant(ContentType.create("text/xml", Consts.UTF_8).toString()))
.to(wsUrl)
.unmarshal(soap)
}
If using the SoapJaxbDataFormat, the resulting xml looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:Envelope xmlns:ns2="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="foo">
<ns2:Body>
<ns4:request xmlns:ns4="bar">
...
Which is incorrect, since the NS for request must be "foo". The XJC-generated request-class I am using contains an @XmlRootElement annotation with the correct NS.
Out of curiosity, I tried JaxbDataFormat for marshalling, the result is correct and I receive:
<ns2:request xmlns:ns2="foo">
Environment:
OS: Windows 7 / 64bit
Camel-Version: 2.12.1
JDK6
Any help is appreciated.
Regards,
Tom
Re: CAMEL-SOAP uses wrong namespace
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You are welcome to submit a patch to fix camel-soap. That component
could use some love. Not everybody really loves SOAP / XML, and think
its cool to improve/fix it in their spare time.
As said many times we love contribtutions
http://camel.apache.org/contributing.html
On Thu, Sep 26, 2013 at 4:36 PM, Ziemer, Tom <to...@wirecard.com> wrote:
> Hi,
>
> I was able to trace the problem to org.apache.camel.dataformat.soap.name.TypeNameStrategy, which is responsible to find the namespace for a given type.
>
> In my case, I had an XJC-generated class that did have an (almost empty) @XmlType and an @XmlRootElement with name and namespace.
>
> The problem was that TypeNameStrategy took the name from the @XmlRootElement and the namespace from @XmlSchema in package-info (generated by xjc). Unfortunately package-info did not contain the correct namespace and that's why an invalid request was assembled.
>
> I am not sure whether TypeNameStrategy is working correctly but I was able to solve my Problem with a custom ElementNameStrategy.
>
> Regards,
> Tom
>
> -----Original Message-----
> Hi,
>
> I have an existing web-service-client (spring-ws+JAXB) that I want to replace with camel. The XSD needed for this WS uses different namespaces for request/response and fault. While trying to migrate to camel/camel-soap, I encountered the following problem:
>
> Request/Response NS: "foo"
> Fault NS: "bar"
>
> Route:
> public void configure() throws Exception {
> SoapJaxbDataFormat soap = new SoapJaxbDataFormat(Request.class.getPackage().getName());
> // soap.setVersion("1.2");
> // JaxbDataFormat soap = new JaxbDataFormat(Request.class.getPackage().getName());
> from("direct:someService")
> .marshal(soap)
> .setHeader(SOAP_ACTION, constant("baz"))
> .setHeader(Exchange.CONTENT_TYPE, constant(ContentType.create("text/xml", Consts.UTF_8).toString()))
> .to(wsUrl)
> .unmarshal(soap)
> }
>
> If using the SoapJaxbDataFormat, the resulting xml looks like:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns2:Envelope xmlns:ns2="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="foo">
> <ns2:Body>
> <ns4:request xmlns:ns4="bar">
> ...
> Which is incorrect, since the NS for request must be "foo". The XJC-generated request-class I am using contains an @XmlRootElement annotation with the correct NS.
>
> Out of curiosity, I tried JaxbDataFormat for marshalling, the result is correct and I receive:
> <ns2:request xmlns:ns2="foo">
>
> Environment:
> OS: Windows 7 / 64bit
> Camel-Version: 2.12.1
> JDK6
>
> Any help is appreciated.
>
> Regards,
> Tom
>
>
>
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
RE: CAMEL-SOAP uses wrong namespace
Posted by "Ziemer, Tom" <to...@wirecard.com>.
Hi,
I was able to trace the problem to org.apache.camel.dataformat.soap.name.TypeNameStrategy, which is responsible to find the namespace for a given type.
In my case, I had an XJC-generated class that did have an (almost empty) @XmlType and an @XmlRootElement with name and namespace.
The problem was that TypeNameStrategy took the name from the @XmlRootElement and the namespace from @XmlSchema in package-info (generated by xjc). Unfortunately package-info did not contain the correct namespace and that's why an invalid request was assembled.
I am not sure whether TypeNameStrategy is working correctly but I was able to solve my Problem with a custom ElementNameStrategy.
Regards,
Tom
-----Original Message-----
Hi,
I have an existing web-service-client (spring-ws+JAXB) that I want to replace with camel. The XSD needed for this WS uses different namespaces for request/response and fault. While trying to migrate to camel/camel-soap, I encountered the following problem:
Request/Response NS: "foo"
Fault NS: "bar"
Route:
public void configure() throws Exception {
SoapJaxbDataFormat soap = new SoapJaxbDataFormat(Request.class.getPackage().getName());
// soap.setVersion("1.2");
// JaxbDataFormat soap = new JaxbDataFormat(Request.class.getPackage().getName());
from("direct:someService")
.marshal(soap)
.setHeader(SOAP_ACTION, constant("baz"))
.setHeader(Exchange.CONTENT_TYPE, constant(ContentType.create("text/xml", Consts.UTF_8).toString()))
.to(wsUrl)
.unmarshal(soap)
}
If using the SoapJaxbDataFormat, the resulting xml looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns2:Envelope xmlns:ns2="http://www.w3.org/2003/05/soap-envelope" xmlns:ns3="foo">
<ns2:Body>
<ns4:request xmlns:ns4="bar">
...
Which is incorrect, since the NS for request must be "foo". The XJC-generated request-class I am using contains an @XmlRootElement annotation with the correct NS.
Out of curiosity, I tried JaxbDataFormat for marshalling, the result is correct and I receive:
<ns2:request xmlns:ns2="foo">
Environment:
OS: Windows 7 / 64bit
Camel-Version: 2.12.1
JDK6
Any help is appreciated.
Regards,
Tom