• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

WSDL with overloaded Operations

 
Keith Smith
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I'm looking for a Valid WSDL with overloaded Operations. Can you direct me to one?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WSDL does not allow inheritance, thus you cannot overload operations.
Kyle
 
Keith Smith
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure? Meaning I can't using Java2WSDL or something similar use a java class with overloaded methods to generate a WSDL wherein i have overloaded operations? I thought this was supported by the spec.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm 99 44/100 percent sure. The developers of WSDL were careful to leave programming concepts like interface inheritance out of the specification. Inheritance is not even in the spec at all. There is one, ambiguous reference to overloading in the spec, (below)
"An operation element within a binding specifies binding information for the operation with the same name within the binding's portType. Since operation names are not required to be unique (for example, in the case of overloading of method names), the name attribute in the operation binding element might not be enough to uniquely identify an operation. In that case, the correct operation should be identified by providing the name attributes of the corresponding wsdl:input and wsdl utput elements."
However, this is not enough to work from. I've doublechecked several WSDL newsgroups that the "real" experts contribute to, and I've seen the answer "no" posted several times.
Kyle
[ April 18, 2002: Message edited by: Kyle Brown ]
 
Keith Smith
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats exactly what I'm talking about. The spec says that two operations within the same PortType can have same name. I'm looking for a valid WSDL describing exactly this scenario.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, I'm an idiot -- now I see what you mean. Comes from thinking too much about inheritance and not about simpler things...
Interesting problem -- I tried working backwards from a Javabean with overloaded method arguments with WebSphere Studio Application Developer 4.0.0 and it failed miserably -- it didn't define the WSDL right.
I'm installing WSAD 4.03 (which fixes many WSDL bugs) and will try again in a minute -- if that fails I'm going to work backwards from the WSDL...
Kyle
Update -- curiouser and curiouser -- WSAD 4.03 actually won't even display the second of two overloaded methods in the view that allows you to select methods to generate WSDL from...this is getting very interesting...
Update 2: Some interesting information here
[ April 22, 2002: Message edited by: Kyle Brown ]
[ April 22, 2002: Message edited by: Kyle Brown ]
 
Marco Palazzini
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I tried to do the same with Sun's Web Services Development Pack (http://java.sun.com/webservices/index.html). I overloaded a method of the tutorial example (HelloWorld) and made it generate the WSDL.
To develop a Web Service using Sun's WSDP you have to specify an interface and its implementation. The tutorial modified by me looks like this:
interface HelloIF.java
--------------------------------------------------
package hello;
import java.rmi.Remote;
import java.rmi.RemoteException;
public interface HelloIF extends Remote {
public String sayHello(String s) throws RemoteException;
public String sayHello(float f) throws RemoteException;
}
--------------------------------------------------
implementation HelloImpl.java
--------------------------------------------------
package hello;
public class HelloImpl implements HelloIF {
public String message = new String("Hello ");
public String sayHello(String s) {
return new String(message + s);
}
public String sayHello(float f) {
return new String(message + f);
}

}
--------------------------------------------------
The WSDL automatically generated:
--------------------------------------------------
<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="HelloWorldService" targetNamespace="http://hello.org/wsdl" xmlns:tns="http://hello.org/wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types />
<message name="sayHello">
<part name="float_1" type="xsd:float" />
</message>
<message name="sayHelloResponse">
<part name="result" type="xsd:string" />
</message>
<message name="sayHello2">
<part name="String_1" type="xsd:string" />
</message>
<message name="sayHello2Response">
<part name="result" type="xsd:string" />
</message>
<portType name="HelloIF">
<operation name="sayHello">
<input message="tns:sayHello" />
<output message="tns:sayHelloResponse" />
</operation>
<operation name="sayHello2">
<input message="tns:sayHello2" />
<output message="tns:sayHello2Response" />
</operation>
</portType>
<binding name="HelloIFBinding" type="tns:HelloIF">
<operation name="sayHello">
<input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="http://hello.org/wsdl" />
</input>
<output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="http://hello.org/wsdl" />
</output>
<soap peration soapAction="" />
</operation>
<operation name="sayHello2">
<input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="http://hello.org/wsdl" />
</input>
<output>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" use="encoded" namespace="http://hello.org/wsdl" />
</output>
<soap peration soapAction="" />
</operation>
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
</binding>
<service name="HelloWorld">
<port name="HelloIFPort" binding="tns:HelloIFBinding">
<soap:address location="REPLACE_WITH_ACTUAL_URL" />
</port>
</service>
</definitions>
--------------------------------------------------
So, it seems that WSDL does not support overloading as in the spec.
Or maybe there is something I am missing...
Marco
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would simply say that Sun's tool doesn't support overloading. I'm a bit disturbed by the fact that Sun's version of the WSDL changed the name...that's not an obvious way of handling the problem...
The example on the link I gave above is valid WSDL -- but it appears that neither IBM's nor Sun's tools will generate anything like it (nor will IBM's tools accept it as input...)
Kyle
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For what it's worth, .Net doesn't support it either. The tutorial says that every method exposed to web services must have a unique name. It forces you to give a "WSDL name" to methods with duplicate names. You end up coding something like this, in front of an overloaded method:
[ WebMethod(MessageName="AddIntegers") ]
where whatever is in MessageName is the Web Services "name" of the method.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You know -- I really like the .NET approach to defining these things. Let's face it the notion of defining web services in your code by (basically) extended comments is just brilliant. I certainly hope that it's one of the good ideas that we can steal and adopt into Java
Kyle
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the two companies that are doing the best work in web services are IBM and Microsoft. I am glad to see that they are working together on SOAP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic