Web Link Exchange Classes

I have written several Java SOAP web services running on JBoss 5.1. Two of them share a class, AddressTO. Webservices are correctly deployed to my ApplicationCationServer, and everything went well until I try to use classTO in my C # client. There are two types in the client application: TO address and TO1 address. This is a problem because it causes errors such as:

Fehler 1 Eine implizite Konvertierung vom Typ "acsysteme.i4workspace.client.webservices.addressTO1[]" in "acsysteme.i4workspace.client.webservices.addressTO[]" ist nicht mΓΆglich. [...] 

This means that you cannot use types implicitly. AddressTo is a bit of a core class that can be used by other web services.

Web links for C # client are created by the team

  wsdl.exe /parameters:CreateWebService.xml 

The xml file contains the URLs for the various .wsdl files of my web services.

Does anyone know how to deal with this problem?

+4
source share
2 answers

Use the /sharetypes when calling wsdl.exe :

/ sharetypes Enables type sharing. This function creates one code file with the definition of one type for identical types shared between other services (namespace, name and proxy signature must be identical). Link to services with http: // URLs as command line parameters or create a discomap document for local files.

If the classes match exactly, they should be generated only once, if you generate code for both services in one command. Both services will use the same class, so no conversion is required.

Edit:

If the XML namespaces do not match (which is common), .NET will treat them as different types, and rightly so. You will either have to fix the web services so that the types are exactly the same (recommended) or do the conversion between the two generated types. This will lead to a big boring property assignment code, so you might want to use something like AutoMapper to handle the conversion for you.

wsdl.exe should generate partial classes , so if you want, you can define implicit conversions between different types:

 public static implicit operator addressTO1(addressTO source) { addressTO1 result = new addressTO1(); // Assign properties, etc. return result; } 

I'm usually not a big fan of implicit conversions, but in this case it may be justified.

+3
source

I solved it!

I used the tip of Thorarin to use the wsdl.exe sharetypes option. But you should not use this option. First, you need to configure the correct namespace (using the URI) in the Webservice class on your java server with the following annotation:

 @WebService(targetNamespace="http://com/project/client/webservices/") public class WebServiceImplementation implements WebService{ // ... your @WebMethod-methods } 

Secondly, you need to change the settings in createWebService.xml accordingly: the web service namespace must be added as follows:

 <wsdlParameters xmlns="http://microsoft.com/webReference/"> <!-- Defaultsettings --> <language>CS</language> <sharetypes>true</sharetypes> <namespace>com.project.client.webservices</namespace> <!-- output --> <out>soap/WebServices.cs</out> <appSettingUrlKey>BaseUrl</appSettingUrlKey> <appSettingBaseUrl>http://localhost:8080</appSettingBaseUrl> <!-- web service locations --> <documents> <document>http://localhost:8080/Core?wsdl</document> <document>http://localhost:8080/WebService0?wsdl</document> <document>http://localhost:8080/WebService1?wsdl</document> </documents> </wsdlParameters> 

What is it! Call wsdl.exe /parameters:createWebService.xml and wsdl.exe /parameters:createWebService.xml done.

Thank you for your help!

+1
source

All Articles