How can I consume a Java based SOAP service that uses a Datahandler type in C#

1.8k Views Asked by At

I'm trying to consume a SOAP service (Agile PLM webservice) using C#, but the SOAP service uses a "Datahandler" type, which seems to be language specific to Java (using Apache Axis library as far as I can tell).

When I try to use the wsdl.exe tool to create a proxy class, it fails due to not having a type for this datahandler. Can anybody suggest how to (cleanly, efficiently) consume this SOAP service without having to hand code a proxy class or manually deal with the SOAP messages in C#?

2

There are 2 best solutions below

4
On BEST ANSWER

First of all, unless you're stuck using .NET 2.0, you shouldn't be using WSDL.EXE. You should be using SVCUTIL.EXE or "Add Service Reference".

In any case, that wouldn't help you consume this broken web service.

Some versions of Apache services that I have seen effectively assume that the consumer is also running Java, and in fact, that it already knows about these data types. That's just plain broken, and cannot be fixed, except by the vendor of the broken web service.

I was under the understanding that later versions of Apache fixed these problems by including the definition of these types in the WSDL.

2
On

You can only use classes consisting of serializable basic types via WebServices... Otherwise there is no way the client could know what that kind of data means. I think your datahandler consists of more than raw data structures...

You could wrap the data in your datahandler in a servicable "view" class like:

class datahandlerView
{
    string a;
    string b;
    List<MyOtherView> list;
}

You can usually just send that over via SOAP and JaxWS if the lists and types are more or less basic Java types. They must be serializable to XML. Don't expose Entities (like from JPA or Hibernate) directly on your WS Endpoint - at least if you have to - be sure that all entity-associations are marked as eager (otherwise the WS call will fail at runtime). Hope that helps.