0

I have a web service written in Java now I want to consume that web service in the .NET world. I use the WSDL to add a proxy class to my .NET application but when I invoke the Java web service method the response is always null. Anyone familiar with this issue?

UPDATE 1:

Another thing I noted is that I opened one of the svcinfo files and found the following code:

<endpoint normalizedDigest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://fff.mywebserive/somewebservie&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;DOC_TOI_Binding&quot; contract=&quot;ServiceReference1.DOC_TOI_PortType&quot; name=&quot;DOC_TOI_Port&quot; /&gt;" digest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data 

This does not look right to me!

UPDATE 2: Solution (Kind of)

The problem was that the response had a different namespace than used by the client proxy class. This way the object was never deserialized correctly. Once, I changed the namespace to match the response namespace it worked fine. But now if I update the web service reference I will again get the same issue as the namespace will be updated. What is a good way to solve this problem? The only solution I can think of is to ask the creator of the webservice to use the correct namespace.

1
  • If you can contact the creator of the web service, then do so, but make sure this is the correct solution to your problem. Commented Oct 26, 2010 at 15:47

2 Answers 2

4

Using .Net, we can add the java web service in our application using Service Referrence or Web Service Referrence.

Service Reference - This is a dedicated way of calling Microsoft WCF Web Services 3.5 and higher. Web Service Reference - Way of referencing Non Microsoft Web Service and lower version of Microsoft webservice such as 2.0

We can also use Service reference in non Microsoft web service, we just need to modify some configuration in app.config such as Security Configurations()

Now, when Invoking the web service request method it always ends up with the NULL object response.

(This is caused by the discrepancy between the proxy namespace expected response and the actual xml namespace webservice response )

Sample: Proxy Code [return: System.Xml.Serialization.XmlElementAttribute("GetResponse ", Namespace = "http://AJ_TUASON.COM ")]

Public GetResponse Get() {}

[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://AJ_TUASON.COM")]

public partial class GetResponse {}

Actual XML Namespace Response

webservice:GetResponse xmlns:"http://AJTUASON.COM"

To resolve this issue, install fiddler2. This will helps you track and confirm that the web services are working fine.

Then, copy the actual namespace in the XML response from web service.

Paste the actual xml namespace response in proxy class of .NET:

Sample: [return: System.Xml.Serialization.XmlElementAttribute("GetResponse ", Namespace = "http://AJTUASON.COM ")] Public GetResponse Get() {}

[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://AJTUASON.COM")] public partial class GetResponse {}

This will resolve the Null issue.

Note: Do not always rely on the tool that generates proxy class. Tools can surely translate but doing analysis is another thing - AJ

Sign up to request clarification or add additional context in comments.

1 Comment

i had the similar issue, i have to figure it out by fixing the namespace.
2

It suggests to me that either your WSDL or your client is incorrect. The client should not be able to tell from the WSDL what language it's implemented in. Check your namespaces.

SOAP UI is a very nice tool for testing SOAP services. I'd recommend it for sorting out this issue.

Looks to me like something tried to escape that snippet. You don't want &gt; you want >

You need to make sure that the service and the client are using the same namespace. Communication is paramount here.

2 Comments

Thanks a lot! I am checking in Fiddler and it shows that the response is sent back correctly but for some reason .NET is not able to handle the response and returns null all the time.
Please read my updated response! I found some weird code in one of my svcinfo xml files in .NET project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.