Help!!! can't invoke a webservice.
Hi guys,
I am in terrible need of having this solved (been on it for 5 days now), it's getting ridiculous, all this hype over webservices ... it ain't workin' for me. Anyhow, here's my stuff...
There's a webservice (wsdl) running on a remote box on IIS. The URL ishttp://xxx.xxx.xxx.xx/pdws/pdwebserv.WSDL
Now, the actual contents of the wsdl file are as follows:
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Generated 05/25/06 by Microsoft SOAP Toolkit WSDL File Generator, Version 3.00.1325.0
-->
- <definitions name="pdwebserv" targetNamespace="http://tempuri.org/pdwebserv/wsdl/" xmlns:wsdlns="http://tempuri.org/pdwebserv/wsdl/" xmlns:typens="http://tempuri.org/pdwebserv/type/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:stk="http://schemas.microsoft.com/soap-toolkit/wsdl-extension" xmlns:dime="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/" xmlns:ref="http://schemas.xmlsoap.org/ws/2002/04/reference/" xmlns:content="http://schemas.xmlsoap.org/ws/2002/04/content-type/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
- <types>
- <schema targetNamespace="http://tempuri.org/pdwebserv/type/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<import namespace="http://schemas.xmlsoap.org/wsdl/" />
<import namespace="http://schemas.xmlsoap.org/ws/2002/04/reference/" />
<import namespace="http://schemas.xmlsoap.org/ws/2002/04/content-type/" />
</schema>
</types>
- <message name="pdwebserv.MainMethod">
<part name="cXMLInput" type="xsd:string" />
<part name="cDataPath" type="xsd:string" />
<part name="cWSPath" type="xsd:string" />
<part name="cXMLOutput" type="xsd:string" />
<part name="cMethod" type="xsd:string" />
</message>
- <message name="pdwebserv.MainMethodResponse">
<part name="Result" type="xsd:anyType" />
</message>
- <portType name="pdwebservSoapPort">
- <operation name="MainMethod" parameterOrder="cXMLInput cDataPath cWSPath cXMLOutput cMethod">
<input message="wsdlns:pdwebserv.MainMethod" />
<output message="wsdlns:pdwebserv.MainMethodResponse" />
</operation>
</portType>
- <binding name="pdwebservSoapBinding" type="wsdlns:pdwebservSoapPort">
<stk:binding preferredEncoding="UTF-8" />
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <operation name="MainMethod">
<soap:operation soapAction="http://tempuri.org/pdwebserv/action/pdwebserv.MainMethod" />
- <input>
<soap:body use="encoded" namespace="http://tempuri.org/pdwebserv/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" parts="cXMLInput cDataPath cWSPath cXMLOutput cMethod" />
</input>
- <output>
<soap:body use="encoded" namespace="http://tempuri.org/pdwebserv/message/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" parts="Result" />
</output>
</operation>
</binding>
- <service name="pdwebserv">
- <port name="pdwebservSoapPort" binding="wsdlns:pdwebservSoapBinding">
<soap:address location="http://xxx.xxx.xxx.xx/pdws/pdwebserv.WSDL" />
</port>
</service>
</definitions>
Now, I am trying from my java code to invoke this webservice using JAX-RPC and the error I am getting is the following:
Exception in thread "main" HTTP Status-Code 405: Method Not Allowed
My code is the following:
import java.net.*;
import java.util.*;
import javax.xml.rpc.*;
import javax.xml.rpc.encoding.*;
import javax.xml.namespace.*;
publicclass Test
{
String wsdlURL ="http://xxx.xxx.xxx.xx/pdws/pdwebserv.WSDL";
String namespaceURI ="http://tempuri.org/pdwebserv/wsdl/";
public Test()throws Exception
{
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new URL(wsdlURL),new QName(namespaceURI,"pdwebserv"));
Call call = service.createCall();
call.setPortTypeName(new QName(namespaceURI,"pdwebservSoapPort"));
call.setOperationName(new QName(namespaceURI,"MainMethod"));
call.setTargetEndpointAddress("http://schemas.xmlsoap.org/soap/http");
call.setProperty("javax.xml.rpc.encodingstyle.namespace.uri","http://schemas.xmlsoap.org/soap/encoding/");
call.setProperty("javax.xml.rpc.soap.http.soapaction.uri","http://tempuri.org/pdwebserv/action/pdwebserv.MainMethod");
call.setProperty("javax.xml.rpc.soap.http.soapaction.use",new Boolean(true));
call.addParameter("cXMLInput",XMLType.XSD_STRING,ParameterMode.IN);
call.addParameter("cDataPath",XMLType.XSD_STRING,ParameterMode.IN);
call.addParameter("cWSPath",XMLType.XSD_STRING,ParameterMode.IN);
call.addParameter("cXMLOutput",XMLType.XSD_STRING,ParameterMode.IN);
call.addParameter("cMethod",XMLType.XSD_STRING,ParameterMode.IN);
call.setReturnType(XMLType.XSD_STRING);
String[] args ={"<?xml version = \"1.0\" encoding=\"UTF-8\" ?> " +
"<VFPDataSet xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"PD_Input.xsd\"> " +
"<PD_Input>" +
"<MasterID>123456</MasterID>" +
"<BillTo>234567</BillTo>" +
"<PDCode>SPORT</PDCode>" +
"<Amount>1000.00</Amount>" +
"</PD_Input>" +
"</VFPDataSet>",
"P:\\","P:\\Pdws\\","","PublDuty"};
System.out.println(call.invoke(args));
}
publicstaticvoid main(String[] args)throws Exception
{
new Test();
}
}
Help guys, this is an emergency!
Thank you all for taking the time to read it and help me.
Steve.

