Pedro
Pedro

Reputation: 2310

Problems consuming a Java/AXIS web service in a .Net Application

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?

Upvotes: 4

Views: 6361

Answers (4)

user306031
user306031

Reputation: 1

I am dealing with the AXIS issues as well and have found some solutions.

I have been integrating with ITIM 5.0 using the unsupported Web Services that use AXIS 1.3. All of the issues I have experienced were fixed in 1.4, and seeing as the product is over 5 years old, I don’t understand why they chose to stick with an older version. There are several issues I have found besides the well published one about how AXIS represents arrays by pointing to a centralized value store. One of those issues is namespacing. AXIS tends to generate WSDL with a namespace, but the return values do not have a namespace, .NET just fails to find the value during deserialization. It took me forever to find out why, but I solved it by manually removing the namespace requirement from the proxy code. The second issue I ran into was how the WSDL represents collections of items. The collection is named SomeCollection with the items underneath being named Item. When the service returns, the items are named the same as the collection (SomeCollection contains SomeCollection(s)). I had to manually rename all of these references in the proxy to be the same as the collection. These cost me countless hours. If I find anymore I will post them here. Obviously the solution is to upgrade to 1.4, but IBM won’t support it or turn over the source code to do so.

Read more in my blog.

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

Upvotes: 0

Cheeso
Cheeso

Reputation: 192417

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.

Upvotes: 1

RichardOD
RichardOD

Reputation: 29157

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)?

Upvotes: 0

Mr. Will
Mr. Will

Reputation: 2308

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.

Upvotes: 0

Related Questions