5

I'm using a 3rd party web service written in Java and using Apache Axis 1.3. The service has many overload operations. When the WCF Svcutil generates the proxy, it renames the overloaded operation by appending a number after the operation name. For example:

getDataResponse getData(getDataRequest request);

getDataResponse1 getData1(getDataRequest1 request);

This by itself isn't a problem, but when Svcutil generates the request/response messages, it neglects to change the WrapperName property of the MessageContracts.

    [MessageContractAttribute(
        WrapperName = "getData", 
        WrapperNamespace = "http://namespace.com", 
        IsWrapped = true)]
    public partial class getDataRequest1 {  ..  }

When the client application attempts to open the proxy, the following exception is thrown:

InvalidOperationException: RPC Message getDataRequest1 in operation getData1 has an invalid body name getData. It must be getData1

If I change WrapperName = "getData1" the proxy will open, however...

  1. I am unable to call the operation because the service doesn't recognize "getData1"
  2. The service has almost 1100 operations, of which nearly half are overloads

Is there any way to generate and/or modify the proxy so that all operations work with WCF?

Mark

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Mark Good
  • 4,271
  • 2
  • 31
  • 43
  • @Mark: have you ever reported this to Microsoft at http://connect.microsoft.com/visualstudio/? – John Saunders Aug 01 '09 at 01:59
  • No I haven't, but I will. Thanks! – Mark Good Aug 01 '09 at 10:56
  • 1
    Maybe this wasn't such a bad question after all? :-) – Mark Good Aug 01 '09 at 10:56
  • I have exactly the same problem. Similarly, a Java Axis2 web service. Did you ever find a solution? – Rebecca Mar 05 '10 at 18:39
  • 1
    Not a good one... I ended up commenting out the overloads that I didn't need. This will come back to haunt me if (read when) the vendor makes breaking changes to their web service. – Mark Good Mar 08 '10 at 15:06
  • [![enter image description here](https://i.stack.imgur.com/MV6k8.png)](https://i.stack.imgur.com/MV6k8.png) I am using vs2019, through this way, it can generate the right code. – Geolle Dec 16 '20 at 09:26

6 Answers6

5

For what it is worth (4 years later), it seems that by calling WSDL.exe manually and passing the /protocol:SOAP parameter, this problem can be avoided. Generating a service client through the UI still seems to cause this issue as of VS2012 for services generated by Apache Axis.

Example usage:

c:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools>wsdl /l:cs /protocol:SOAP http://rxnav.nlm.nih.gov/RxNormDBService.xml /out:c:\drop\rxnavapi.cs

Edit: sphinxxx correctly noted that the SOAP protocol option is exposed in UI as "Add Web Reference", so executing wsdl.exe directly is not necessary.

Community
  • 1
  • 1
Mitch
  • 21,223
  • 6
  • 63
  • 86
  • 1
    Thanks a lot, that solved the problem! I also found that you _can_ use the "Add Service Reference" dialog if you click [Advanced] and then choose [Add Web Reference] instead (I use VS2012). – Sphinxxx Jun 06 '13 at 08:01
3

The only workaround that I have been able to find is to edit the generated code by hand and remove all of the overloads that I don't need.

Mark Good
  • 4,271
  • 2
  • 31
  • 43
  • Is this still the only option or have you found in other way? – Aaron McIver Feb 23 '11 at 18:00
  • To be honest, I haven't tried to find another way yet. I wishful that Microsoft can (and will eventually) do something with SvcUtil to generate a usable client. But I'm not holding my breath. – Mark Good Feb 23 '11 at 21:01
1

I didn't see this question before, because you had a "java" tag on it, and I ignore Java questions. Your question wasn't about Java, so should not have had a "java" tag.

svcutil is not renaming the overloaded operations. That's because there's no such thing as overloaded operations. WSDL has no concept of two operations with the same name, but using different messages.

If you look at the WSDL from Axis, I believe you'll find the operations have the numbers appended to them.


Correction: In a comment, Mark Good correctly points out that WSDL 1.1 does permit overloading. I happen to think it only makes any sense in the context of an RPC-based service, where the message name can be used to distinguish between one overload and another.

However, he may not be aware that operator overloading is prohibited by WS-I Basic Profile 1.1:

4.5.3 Distinctive Operations

Operation name overloading in a wsdl:portType is disallowed by the Profile.

R2304 A wsdl:portType in a DESCRIPTION MUST have operations with distinct values for their name attributes.

Note that this requirement applies only to the wsdl:operations within a given wsdl:portType. A wsdl:portType may have wsdl:operations with names that are the same as those found in other wsdl:portTypes.


If one reads more of WS-I BP1.1, one will learn why not everything in WSDL 1.1 is a good idea.

Community
  • 1
  • 1
John Saunders
  • 160,644
  • 26
  • 247
  • 397
  • The question stood for months without the Java tag and you did not answer. I recently added the java tag because the 3rd part software was written in Java and I was hoping that someone might be able to offer a way to generate the WSDL differently. From what I read, overloading operations WAS supported in WSDL 1.1 (ref http://webservices.xml.com/pub/a/ws/2003/01/08/randyray.html). You are incorrect about svcutil not renaming the operations and the operations having numbers appended to them in the WSDL. I can send you and/or post a snippet on Monday if you would like. – Mark Good Aug 01 '09 at 01:34
  • I don't actually see every question that everyone posts. I only got around to this one due to being unemployed. I hope soon to be seeing fewer posts – John Saunders Aug 01 '09 at 01:41
  • I wasn't specifically aware that it was prohibited by WS-I Basic Profile 1.1, but thanks for the info. Sorry to hear about your unemployment. I with you luck with fewer posts. :-) – Mark Good Aug 01 '09 at 10:54
  • Take the opportunity to read http://www.ws-i.org/Profiles/BasicProfile-1.1.html. It's quite instsructive, and teaches a lot about how not to write a specification (SOAP, WSDL). – John Saunders Aug 01 '09 at 11:42
0

I have found that when using "old fashioned" AddServiceReference, it correctly generates classes with overloads, even in VS2012.

Boaz
  • 19,892
  • 8
  • 62
  • 70
Jiří Zídek
  • 416
  • 3
  • 9
0

None of the solutions here worked for me.

Generating the reference in a vs2010 project targeted for .NET2, and then opening the solution in vs2012 or vs2013 targeting .NET4, does work though.

user326608
  • 2,210
  • 1
  • 26
  • 33
0

Write a script that'll do this text fix and set it as the post-build script for your proxy library.

Sijin
  • 4,530
  • 21
  • 22