Hi,
I read an example of using Apache SOAP, the client doesn't use WSDL to send SOAP request. they just use the following code fragment :
public class CalcClient {
public static void main(
String[] args) throws Exception {
URL url = new URL ("http://localhost:8080/soap/servlet/rpcrouter");
Integer p1 = new Integer(args[0]);
Integer p2 = new Integer(args[1]);
/***********************************************************/
// Build the call.
Call call = new Call();
call.setTargetObjectURI("urn
njavaserver");
call.setMethodName("subtract");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector();
params.addElement(new Parameter("p1", Integer.class, p1, null));
params.addElement(new Parameter("p2", Integer.class, p2, null));
call.setParams (params);
// make the call: note that the action URI is empty because the
// XML-SOAP rpc router does not need this. This may change in the
// future.
Response resp = call.invoke(url, "" );
/*********************************************************************/
// Check the response.
if ( resp.generatedFault() ) {
Fault fault = resp.getFault ();
System.out.println("The call failed: ");
System.out.println("Fault Code = " + fault.getFaultCode());
System.out.println("Fault String = " + fault.getFaultString());
}
else {
Parameter result = resp.getReturnValue();
System.out.println(result.getValue());
}
}
}
deployment descriptor :
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
id="urn
njavaserver">
<isd
rovider type="java"
scope="Application"
methods="add subtract">
<isd:java class="onjava.CalcService"/>
</isd
rovider>
<isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
</isd:service>
web services method :
package onjava;
public class CalcService {
public int add(int p1, int p2) {
return p1 + p2;
}
public int subtract(int p1, int p2) {
return p1 - p2;
}
}
It seems it doesn't use WSDL, but still can send SOAP request to SOAP server. Therefore, right now, I am confused that whether WSDL is necessary in a web services application.
Please help.
Benson