Friday, January 8, 2010

.NET and Apache Axis Interop Problem

I've been using Apache Axis for a long time to publish web services in Java apps.  But recently, it's the first time that a .NET client is used to call the web services published via Axis.  Although I do not have the exact error messages in the .NET client, the client mentioned they received "null" errors when parsing the response.

First thing to do was to disable "multirefs" output.  This can be achieved by adding the following parameter in either the global configuration or service based configuration.  Either way, output below shows the tag to disable sending "multiref" output:
<parameter name="sendMultiRefs" value="false"/>
The second option I tried was to turn on the "dotNetSoapEncFix".  Again, this can be applied in the global or service configuration.  Setting shown below:
<parameter name="dotNetSoapEncFix" value="true"/>
Unfortunately, I didn't have much luck with the "dotNetSoapEncFix" parameter.  The last thing I tried was to change the output style to "wrapped".  This option can only be turned on in the service tag.  Here's how I did it:
<service name="myService" provider="java:RPC" style="wrapped"/>
After the server's restarted, the output is a lot shorter without the "soapenc" definitions which were causing the problems.

Here's the output before setting the style to "wrapped":

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <ns1:function1 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://com.testing">
         <function1_Return xsi:type="ns2:Map" xmlns:ns2="http://xml.apache.org/xml-soap">
            <item xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
               <key xsi:type="soapenc:string">DESC</key>
               <value xsi:type="soapenc:string">EXCEPTION</value>
            </item>
            <item>
               <key xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">STATUS</key>
               <value xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0</value>
            </item>
         </function1_Return>
      </ns1:function1>
   </soapenv:Body>
</soapenv:Envelope>

Here's the output after:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <function1 xmlns="http://com.testing">
         <function1_Return>
            <item xmlns:ns1="http://xml.apache.org/xml-soap" xmlns="">
               <key xsi:type="xsd:string">DESC</key>
               <value xsi:type="xsd:string">EXCEPTION</value>
            </item>
            <item xmlns="">
               <key xsi:type="xsd:string">STATUS</key>
               <value xsi:type="xsd:string">0</value>
            </item>
         </function1_Return>
      </function1>
   </soapenv:Body>
</soapenv:Envelope>

No comments: