Hi,
I have to execute a remote webservice in my Plain Java Program.
I am using JAX PRC and here is the code snippet.
/**
* Created by IntelliJ IDEA.
* User: dharanish.balineni
* Date: Jun 5, 2007
* Time: 3:35:43 PM
* To change this template use File | Settings | File Templates.
*/
import java.net.URL;
import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.Call;
public class TestWebServ {
public static void main(String args[]){
String qnameService = "CTMSuppliesWS";
String qnamePort = "Config1Port_Document";
String BODY_NAMESPACE_VALUE = "urn:CTMSuppliesWSWsd";
String ENCODING_STYLE_PROPERTY =
"javax.xml.rpc.encodingstyle.namespace.uri";
String NS_XSD = "
http://www.w3.org/2001/XMLSchema";
String URI_ENCODING =
"
http://schemas.xmlsoap.org/soap/encoding/";
String webServiceAddress =
"
http://sapwp14:50000/CTMSuppliesWS/Config1?wsdl&style=rpc";
try{
ServiceFactory factory =
ServiceFactory.newInstance();
Service service = factory.createService( new
QName(qnameService));
QName port = new QName (qnamePort);
Call call = service.createCall(port);
call.setTargetEndpointAddress(webServiceAddress);
//call.setProperty(ENCODING_STYLE_PROPERTY,URI_ENCODING);
call.setProperty(Call.USERNAME_PROPERTY,"administrator");
call.setProperty(Call.PASSWORD_PROPERTY,"Password1");
QName QNAME_TYPE_VECTOR = new
QName(NS_XSD,"vector");
QName QNAME_TYPE_INT = new QName(NS_XSD,"int");
call.setReturnType(QNAME_TYPE_VECTOR);
call.setOperationName(new
QName(BODY_NAMESPACE_VALUE,"findAll"));
Integer params[] = new Integer[1];
call.invoke(params);
}catch(Exception e){
e.printStackTrace();
}
}
}
Here is the WDSL .
<?xml version="1.0" encoding="utf-8" ?>
- <!--
Generated by WSDLDefinitionsParser
-->
<
http://sapwp14:50000/CTMSuppliesWS/Config1?wsdl&style=rpc##> -
<wsdl:definitions xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/"
name="CTMSuppliesWSWsd" targetNamespace="urn:CTMSuppliesWSWsd"
xmlns:bns0="urn:CTMSuppliesWSWsd/Config1/rpc"
xmlns:soap="
http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:import
location="
http://sapwp14:50000/CTMSuppliesWS/Config1/bindings?wsdl&style
=rpc" namespace="urn:CTMSuppliesWSWsd/Config1/rpc" />
<
http://sapwp14:50000/CTMSuppliesWS/Config1?wsdl&style=rpc##> -
<wsdl:service name="CTMSuppliesWS">
<
http://sapwp14:50000/CTMSuppliesWS/Config1?wsdl&style=rpc##> -
<wsdl:port name="Config1Port_Rpc" binding="bns0:Config1Binding">
<soap:address
location="
http://sapwp14:50000/CTMSuppliesWS/Config1?style=rpc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I am getting the following exception while running the app.
operation style: "rpc" not supported
at
com.sun.xml.rpc.client.dii.BasicCall.unsupportedOperationStyleException(
BasicCall.java:566)
at
com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:498)
at TestWebServ.main(TestWebServ.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Can anybody please help me.
Regards
Dharanish Balineni
@ris global
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately