views:

1371

answers:

4

Hi, I have to consume a Web Service that is written in Java by a 3rd party, generated with Axis I guess.

I'm using .Net Framework 3.5 SP1 and VS 2008.

I've made a Web Reference, as we used to make in .net 2.0, and pointed it to the wsdl of the service.

It worked perfectly with some methods of the service, but when I try to call a Method that takes an int as a parameter, the following exception is thrown:

JAXRPCTIE01: caught exception while handling request:  
unexpected element type:  
expected={http://schemas.xmlsoap.org/soap/encoding/}int,
actual={http://www.w3.org/2001/XMLSchema}int

I checked the wsdl and it defines five different Xml Schema Namespaces:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"  
xmlns:tns="urn:servicos/wsdlservicosgmp2"  
xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/"  
xmlns:ns3="urn:servicos/typesservicosgmp2"  
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
name="servicosgmp2"  
targetNamespace="urn:servicos/wsdlservicosgmp2">

<schema xmlns="http://www.w3.org/2001/XMLSchema"  
xmlns:tns="urn:servicos/typesservicosgmp2"  
xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/"  
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  
targetNamespace="urn:servicos/typesservicosgmp2">

And the definition of the problematic method:

<message name="IWsServicosGMP2_buscaConvenio">  
<part name="Integer_1" type="ns2:int" />  
<part name="Integer_2" type="ns2:int" />  
</message>

Anyone has a clue of what I have to do to solve this problem?

A: 

You will need to go into the proxy classes generated by .NET and manually change the namespace for the input parameters to the one the Axis code is using. Hopefully that will work.

I have been doing some reading and it seems that Axis does not always work well with .NET.

Mr. Will
Thanks, I'll try that and will let you know if I succeed.
Pedro
actually kind of sounds like it's the fault of whatever is generating the proxy classes on the .NET side (assuming that the WSDL has the correct namespace)
matt b
A: 

I'm not sure if this will help but it may be worth a try. Have you tried adding a Service Reference (svcutil.exe wrapper) instead of Web reference (wsdl.exe wrapper)?

RichardOD
+1  A: 

It seems the Java/AXIS web service is using SOAP (section 5) encoding. This is a throwback, and is very odd to see these days.

Where'd you get the web service? how long has it been running? Do you have the ability to change it? AXIS or AXIS2? What version? For AXIS1, anything from AXIS v1.1 onward should work ok, but I'd advise updating to v1.4. If possible move to AXIS2, and use v1.4. (Confusingly, AXIS and AXIS2 are at the same version number.)

Why does the Java side want to use SOAP encoding? Did the Java side take a WSDL first approach, or is this one of those dynamically-generated WSDL things? AXIS and .NET work together just fine, if you start with WSDL+XSD first, and confine yourself to doc/lit webservices and confine your use of xmlschema to the less exotic pieces: primitives, and structures and arrays of same. You can nest to any level: arrays of structures containing arrays, structures containing arrays of structures, etc etc.

Addendum: If you start with your Java object model, and try to dynamically generate a wire-interface from it (eg, WSDL), you tend to get much worse interop, and you tend to think in terms of sending objects over the wire instead of messages, which can be harmful.

Things to avoid: lists, restrictions, substitution groups, and other wacky things.

Cheeso
Hi Cheeso, I got this WebService from a third party company. They've just developed it for a integration solution we are making.Well, thanks for your answer and I'll let them know of everything you've said.I guess they've taken the dynamically generated WSDL approach. That's probably the root of our problems.Thanks again.
Pedro
Yes, if they want interop, then WSDL-first is the right way to go. There are lots of good resources on the web on how to do that.
Cheeso
Cheeso, thanks.I'm not sure what was the approach they've taken, but after I talked with them about you've told me, they made some changes on the service and it is working as expected right now.Thanks again.
Pedro
A: 

Read some of the information my blog. I am dealing with the AXIS issues as well and have found some solutions.

http://nbaked.wordpress.com/2010/04/01/issues-integrating-axis-web-services-with-net/