Search code examples
c#jsonweb-servicessoapnusoap

passing json string as parameter to webmethod[SOAP web service] written in C#?


I have written one Soap Web Service in asp.net web application.In that C# web service,i have one web method that takes json string as a argument.Now i want to invoke this soap web service from php based client.

My question is "basically Soap web service is based on xml. So, Is this legal to pass json string as a parameter to my Soap Web service in C#(Server) environment.

Or is it better consume json web service on C# environment instead of above one?

please lead me to get the clear approach?

Thanks in Advance...


Solution

  • Soap uses Xml as the transport format but that isn't really an issue for you since i can see that you are using NuSoap.

    You can pass json as the parameter. You could set the parameter type of the webservice to string and on the c# side you can parse the json using JSON.NET or any similar parser.

    I'd typically create a type to represent the json fields and de-serialize the json to the type for ease of use.