Meaningless Drivel is fun!*
The moose likes Web Services and the fly likes WSDL with overloaded Operations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "WSDL with overloaded Operations" Watch "WSDL with overloaded Operations" New topic
Author

WSDL with overloaded Operations

Keith Smith
Greenhorn

Joined: Apr 18, 2002
Posts: 6
Hi. I'm looking for a Valid WSDL with overloaded Operations. Can you direct me to one?
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
WSDL does not allow inheritance, thus you cannot overload operations.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Keith Smith
Greenhorn

Joined: Apr 18, 2002
Posts: 6
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

Joined: Aug 10, 2001
Posts: 3892
    
    5
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

Joined: Apr 18, 2002
Posts: 6
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

Joined: Aug 10, 2001
Posts: 3892
    
    5
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

Joined: Apr 18, 2002
Posts: 13
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

Joined: Aug 10, 2001
Posts: 3892
    
    5
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

Joined: May 05, 2000
Posts: 13974
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.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
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

Joined: May 05, 2000
Posts: 13974
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: WSDL with overloaded Operations
 
Similar Threads
How to generate a correct WSDL for a service with overloaded methods ?
WSDL with overloaded operations
WSDL 2.0 - overloaded operation ?
Overloaded operations
Question about expose overloaded session bean method as web service.