0

I have a ASP.NET 2.0 webservice that is being invoked from JAX-WS 2.1. If I test with SOAP UI it works. SOAP UI generates a request of the form

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sup="abc.123">
   <soapenv:Header/>
   <soapenv:Body>
      <sup:Method>
         <sup:element>GBA</sup:element>
         <sup:attributes>
            <sup:Attribute>
               <sup:attributeName>XYZ</sup:attributeName>
               <sup:attributeValue>123</sup:attributeValue>
            </sup:Attribute>
         </sup:attributes>
         <sup:nop>abc</sup:nop>
         <sup:data>1</sup:data>
      </sup:Method>
   </soapenv:Body>
</soapenv:Envelope>

This works correctly, and the web service receives and correctly processes the data. However the JAX-WS client creates a request of the form

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <Method xmlns="abc.123">
      <element>
        <name>GBA</name>
      </element>
      <attributes>
        <Attribute>
          <attributeName>XYZ</attributeName>
          <attributeValue>123</attributeValue>
        </Attribute>
      </attributes>
      <nop>abc</nop>
      <data>1</data>
    </Method>
  </soapenv:Body>
</soapenv:Envelope>

This does not work correctly. The ASP.NET webservice interprets all the parameters except element as null. Obviously this causes processing to fail. A message is returned and correctly interpreted by the JAX-WS proxy.

How can I force JAX-WS (either in the client generation or in the code) to use the namespace prefix? Alternatively is there a way to tell ASP.NET how to interpret the SOAP message as is?


So far I've read up on JAX-WS and it seams to have plenty of options for customizing the java created, but I haven't found any parameters or binding rules for customizing how it creates the SOAP.

The only thing I have found that looks promising is using a SoapHandler to manually edit the xml construct, as was suggested in this answer. However this involves writing code to walk the DOM and prepend the prefix to each node. I haven't successfully tested this option yet ...

Community
  • 1
  • 1
C. Ross
  • 31,137
  • 42
  • 147
  • 238
  • I see three issues with your question: 1- I think your question presumes that ASPNET requires a specific namespace prefix. This is not true. 2- your sample request shows the use of an attribute `xmlnx`. This is not xmlns, and if the message really does use `xmlnx`, that would be enough to make it not work. 3- you do not specify the xml namespace associated to the `xyz` in the original, working soap request. If it is different from the xml namespace for the JAX-WS request, the JAX-WS request won't work. – Cheeso Nov 10 '11 at 22:42
  • @Cheeso This is mock data, I already corrected the xmlns. I will update with more realistic mock data. As for 1, I realize it doesn't require a *specific* prefix, but I do think it requires a prefix. – C. Ross Nov 10 '11 at 22:57
  • With the information you provide, there's nothing wrong with the request. It does not require a prefix, it requires a namespace. The namespace may be provided with a prefix or not. The concept of the *XML Infoset* is the critical thing here. If the infosets of the messages are equivalent, the messages will be treated equivalently by the server. When you say "it doesn't work" - exactly what is the symptom? Have you traced the messages on the wire? It is possible that ASPNET treats the request as valid, issues a valid response, and the JAX-WS client is choking on the response. – Cheeso Nov 10 '11 at 23:36
  • @Cheeso I agree it's valid. The symptom is that in the ASP.NET method (my code) several of the fields, the list of Attributes for example, are null. I've checked on the wire, and that's where I get request example 2. – C. Ross Nov 10 '11 at 23:41
  • Whoops - check that - your `` attribute differs between the first message and the second. That will be the source of the problem. – Cheeso Nov 10 '11 at 23:41

2 Answers2

0

The <element> attribute differs between the first message and the second. That will be the source of the problem.

The SOAP UI:

  ...
  <sup:element>GBA</sup:element>  

The JAX-WS:

   ....
  <element> 
    <name>GBA</name> 
  </element> 

The xml namespaces are equivalent. It is the element names themselves that differ.

Cheeso
  • 189,189
  • 101
  • 473
  • 713
  • Oddly enough, that is the one and only element that is coming through correctly. I kid you not. – C. Ross Nov 10 '11 at 23:52
0

The client was generated using an old version of the WSDL. Using a current version of the WSDL corrected the problem.

Always check to make sure the WSDL's for the client and server match.

C. Ross
  • 31,137
  • 42
  • 147
  • 238