Glen Mazza wrote:
>
> And then ran this test case with it:
>
> public void doubleItWorksForPrimeNumbers() throws Exception {
> Service jaxwsService = Service.create(wsdlURL, serviceName);
> DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder builder = factory.newDocumentBuilder();
> InputStream is =
> getClass().getClassLoader().getResourceAsStream("justPayload.xml");
> Document newDoc = builder.parse(is);
> DOMSource request = new DOMSource(newDoc);
> Dispatch<Source> disp =
> jaxwsService.createDispatch(portName, Source.class,
> Service.Mode.PAYLOAD);
> Source result = disp.invoke(request);
> DOMResult domResponse = new DOMResult();
> Transformer trans =
> TransformerFactory.newInstance().newTransformer();
> trans.transform(result, domResponse);
> assertEquals("Double-It failing with prime numbers", "14",
>
> domResponse.getNode().getFirstChild().getTextContent().trim());
> }
>
> Wireshark reports this:
>
> <SOAP-ENV:Header/>
> <SOAP-ENV:Body>
> <ns2:DoubleIt xmlns="http://www.example.org/DoubleIt"
> xmlns:ns2="http://www.example.org/DoubleIt">
> <numberToDouble xmlns="">7</numberToDouble>
> </ns2:DoubleIt>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> In this case, it seems that CXF is suppressing the namespace of
> numberToDouble, by explicitly making it the null namespace. Is there a
> problem here between the two SOAP requests--or are they both saying the
> same thing? Note the default namespace is not mentioned in the wsdl2java
> SOAP request but is declared here in the Dispatch one. CXF seems to be
> making a strange decision here--it sets the default namespace to that of
> the parent-level item (xmlns is the same as xmlns:ns2), but the explicitly
> zeros it out for child elements of that top-level item.
>
Figured out the problem--I needed to call factory.setNamespaceAware(true) to
fix the problem. Now the SOAP request has the proper namespace for
numberToDouble:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ...>
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:DoubleIt xmlns:ns2="http://www.example.org/DoubleIt">
<numberToDouble>7</numberToDouble>
</ns2:DoubleIt>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Glen
--
View this message in context:
http://www.nabble.com/CXF-Bug-with-Dispatch%3CSource%3E-and-Service.Mode.PAYLOAD--tp19089782p19194014.html
Sent from the cxf-user mailing list archive at Nabble.com.