0

I have an .net 2.0 C# client app that has a web service reference to an Axis2 Java Webservice. The idea is to send some xml data to the webservice, so it can be parsed and inserted into database. The WS method accepts a single parameter of type 'xsd:anytype'.

Java web service:

public class JWS{    
    public Response AddData(Object inputXML) {            
        return Response;
    }  
}

C# Client:

JWS client = new JWS();
object inputXML = "<xml>some xml data</xml>";
response = client.AddData(inputXML);

There are 2 issues i am seeing when monitored using fiddler.

1) The request has an additional element '<inputXML>' added before the actual xml data.

<inputXML>&lt;xml&gt;some xml data&lt;/xml&gt;</inputXML>

2) The xml is encoded, so '<' is appearing as "&lt;"

I am not sure if this is how SOAP request's are generated but i would like to remove the <inputXML> tag and also, have the xml appear as is without having to replace the special characters.

Is this possible? Is it got something to do with 'Wrapping'/'UnWrapping' Types?

Also, i have used SoapUI to test the java web service and it works well. However, in the request tab, i had to manually remove the <inputXML> tag and submit for it to work correctly. Please help.

TIA

SoftwareGeek
  • 15,234
  • 19
  • 61
  • 78

2 Answers2

1

This is expected behaviour under SOAP and the inputXml variable will be decoded back to the original string when passed to your web service method.

However this may indicate a problem with your design, have you considered constructing an object to send to your web service rather than xml data? (As this object will transparently be converted to xml for the web service call anyway).

  • could you provide an example? – SoftwareGeek Jun 08 '11 at 02:27
  • sorry I'm a bit unsure about the problem you are having, are you able to give more detail on how you are generating the c# client and can you give output on the actual error thrown? Do you have the web service in a debugger to get the actual value of inputXML ? – Richard Blackman Jun 08 '11 at 02:38
  • i added a web service reference in a c# project to the java ws. when i debug, i see the request & response using fiddler & my entire xml is received by the java webservice but the xml is encoded and also, just before the xml there is another element with the same name as the parameter (inputXML). Is this how it works? – SoftwareGeek Jun 09 '11 at 00:25
  • yep that's how it works, axis should strip off the `inputXML` tag and then turn your encoded xml back. Inside the `AddData` method you will find your original `some xml data` string. – Richard Blackman Jun 09 '11 at 07:07
  • _Is it got something to do with 'Wrapping'/'UnWrapping' Types?_ in other words you are correct here. – Richard Blackman Jun 09 '11 at 08:52
  • No problem, glad you got it sorted out. – Richard Blackman Jun 16 '11 at 01:23
0

I found out that the issue is not with encoding but it was interpreted incorrectly on java side when the message was viewed in axis2. So, it is getting decoded properly. Also, the inputxml is now being handled correctly.

SoftwareGeek
  • 15,234
  • 19
  • 61
  • 78