Hello, I'm trying to make a test case for my DoubleIt web service sample
using Dispatch<Source> and Service.Mode.PAYLOAD.  It seems to work for CXF
but I'm noticing something strange over the wire with Wireshark.

1.)  The WSDL I'm using is here: 
http://www.jroller.com/gmazza/date/20080417#WFstep5

In particular, this is the input type being used:

      <xsd:schema targetNamespace="http://www.example.org/DoubleIt";>
         <xsd:element name="DoubleIt">
            <xsd:complexType>
               <xsd:sequence>
                  <xsd:element name="numberToDouble" type="xsd:integer"/>
               </xsd:sequence>
            </xsd:complexType>
         </xsd:element>

If I understand by XSD correctly, I assume this means that the namespace of
numberToDouble above is http://www.example.org/DoubleIt, correct?

2.)  When I run the simple SOAP client using wsdl2java generated objects as
here:
http://www.jroller.com/gmazza/date/20080417#WFstep10

The request works fine.  This is what Wireshark reports was sent out as a
request:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
   <soap:Body>
      <ns2:DoubleIt xmlns:ns2="http://www.example.org/DoubleIt";>
         <numberToDouble>7</numberToDouble>
      </ns2:DoubleIt>
   </soap:Body>
</soap:Envelope>

Again, I think numberToDouble is keeping the http://www.example.org/DoubleIt
namespace, even though it is not qualified as such (i.e.,
ns2:numberToDouble)--am I correct here?

3.) The problem is with Dispatch<Source> and Service.Mode.PAYLOAD.  I
stripped out the <ns2:DoubleIt/> section above and placed it in a separate
file:

<ns2:DoubleIt xmlns:ns2="http://www.example.org/DoubleIt";>
   <numberToDouble>7</numberToDouble>
</ns2:DoubleIt>

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.

(Dispatch<DOMSource> does the same as Dispatch<Source>, BTW.  I have to use
the latter because the former isn't supported by Metro.)

Metro is not helping me in determining the problem, because it appears to
have a bug with the above code.  It generates this with the above code:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/";>
<S:Body>
<ns2:DoubleIt xmlns:xmlns:ns2="http://www.example.org/DoubleIt";>
   <numberToDouble>7</numberToDouble>
</ns2:DoubleIt>
</S:Body>
</S:Envelope>

Which is a syntax error-- you can see the "xmlns:xmlns:ns2" next to
DoubleIt, which subsequently fails when sent to the web service provider. 
(I'll send a bug report to them next on this...)

Thanks,
Glen
-- 
View this message in context: 
http://www.nabble.com/CXF-Bug-with-Dispatch%3CSource%3E-and-Service.Mode.PAYLOAD--tp19089782p19089782.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to