You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by "Kapoor, Nishikant" <ni...@xcelenergy.com> on 2003/12/11 19:02:10 UTC
How to pass params to SOAP server using sockets?
Hello,
I have a question and I hope I'll be able to get some help from the list.
Most of the SOAP examples that I have seen and worked with so far use RPC to connect to SOAP server as:
---------------start - RPC-----------------------
import org.apache.soap.rpc.*;
URL url = new URL("http://genx:80/soap/servlet/rpcrouter");
Call call = new Call();
call.setTargetObjectURI("urn:XcelXmlServer");
call.setMethodName("getMeaning");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector();
params.addElement (new Parameter ("wordToLookup", String.class, "toughWord", null));
call.setParams(params);
Response resp = call.invoke(url, "");
Fault fault = resp.getFault();
System.out.print (result.getValue());
---------------end - RPC -----------------------------
But, I need to use sockets instead:
---------------start - Socket -----------------------------
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
String host = "genx"; int port = 80;
String submitURL = "/soap/servlet/rpcrouter";
sslSocket = (SSLSocket)factory.createSocket(host, port);
sslSocket.startHandshake();
socket = new Socket(host, port);
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));
out.println("POST " + submitURL + " HTTP/1.1");
out.println("Host: " + host);
out.println("Content-Type: text/xml");
out.println("Content-Length: " + "toughWord".length());
out.println("SOAPAction: \"\"" + "\n");
out.println(SOAP_HEADER + "\n" + toughWord + "\n" + SOAP_FOOTER);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
socket.close();
---------------end - Socket -----------------------------
I have implemented service 'Dictionary' that has a method 'getMeaning'. I can access it via RPC but not via sockets. The values in the above code snippet are the exact values that I am using in my program.
My question is: Where (and how) in sockets do I specify the equivalent of
call.setTargetObjectURI("urn:XcelXmlServer");
call.setMethodName("getMeaning");
Thanks
Nishi
Re: How to pass params to SOAP server using sockets?
Posted by John Lewis <ub...@sneakemail.com>.
To remove your address from the list, send a message to:
> <so...@ws.apache.org>
>
>
Have a good one. :)
myname last name dsl_germany-at-yahoo.com |apache soap| wrote:
> How can I unsubscribe from this forum
>
> */Scott Nichol <sn...@scottnichol.com>/* wrote:
>
> I have to ask: why do you need to work directly with sockets? Do
> you have some requirement that you cannot use a SOAP library?
>
> To answer your questions, the targetObjectURI is the namespace for
> the service, which effectively means it is the namespace of the
> method element. That gets to your second question, the
> setMethodName is specifying the name of the method element.
>
> Your SOAP payload should look something like
>
>
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>
>
> SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> toughWord
>
>
>
>
> Scott Nichol
>
> Do not send e-mail directly to this e-mail address,
> because it is filtered to accept only mail from
> specific mail lists.
>
> ----- Original Message -----
> From: "Kapoor, Nishikant"
> To:
> Sent: Thursday, December 11, 2003 1:02 PM
> Subject: How to pass params to SOAP server using sockets?
>
>
> Hello,
>
> I have a question and I hope I'll be able to get some help from
> the list.
>
> Most of the SOAP examples that I have seen and worked with so far
> use RPC to connect to SOAP server as:
> ---------------start - RPC-----------------------
> import org.apache.soap.rpc.*;
> URL url = new URL("http://genx:80/soap/servlet/rpcrouter");
> Call call = new Call();
> call.setTargetObjectURI("urn:XcelXmlServer");
> call.setMethodName("getMeaning");
> call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> Vector params = new Vector();
> params.addElement (new Parameter ("wordToLookup", String.class,
> "toughWord", null));
> call.setParams(params);
> Response resp = call.invoke(url, "");
> Fault fault = resp.getFault();
> System.out.print (result.getValue());
> ---------------end - RPC -----------------------------
>
> But, I need to use sockets instead:
>
> ---------------start - Socket -----------------------------
> import javax.net.ssl.SSLSocket;
> import javax.net.ssl.SSLSocketFactory;
> String host = "genx"; int port = 80;
> String submitURL = "/soap/servlet/rpcrouter";
> sslSocket = (SSLSocket)factory.createSocket(host, port);
> sslSocket.startHandshake();
> socket = new Socket(host, port);
> out = new PrintWriter(new BufferedWriter(new
> OutputStreamWriter(socket.getOutputStream())));
> out.println("POST " + submitURL + " HTTP/1.1");
> out.println("Host: " + host);
> out.println("Content-Type: text/xml");
> out.println("Content-Length: " + "toughWord".length());
> out.println("SOAPAction: \"\"" + "\n");
> out.println(SOAP_HEADER + "\n" + toughWord + "\n" + SOAP_FOOTER);
> in = new BufferedReader(new
> InputStreamReader(socket.getInputStream()));
> while ((inputLine = in.readLine()) != null)
> System.out.println(inputLine);
> socket.close();
> ---------------end - Socket -----------------------------
>
> I have implemented service 'Dictionary' that has a method
> 'getMeaning'. I can access it via RPC but not via sockets. The
> values in the above code snippet are the exact values that I am
> using in my program.
>
> My question is: Where (and how) in sockets do I specify the
> equivalent of
>
> call.setTargetObjectURI("urn:XcelXmlServer");
> call.setMethodName("getMeaning");
>
>
> Thanks
> Nishi
>
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Protect your identity with Yahoo! Mail AddressGuard
> <http://antispam.yahoo.com/whatsnewfree>
Re: How to pass params to SOAP server using sockets?
Posted by myname last name <ds...@yahoo.com>.
How can I unsubscribe from this forum
Scott Nichol <sn...@scottnichol.com> wrote:I have to ask: why do you need to work directly with sockets? Do you have some requirement that you cannot use a SOAP library?
To answer your questions, the targetObjectURI is the namespace for the service, which effectively means it is the namespace of the method element. That gets to your second question, the setMethodName is specifying the name of the method element.
Your SOAP payload should look something like
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
toughWord
Scott Nichol
Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message -----
From: "Kapoor, Nishikant"
To:
Sent: Thursday, December 11, 2003 1:02 PM
Subject: How to pass params to SOAP server using sockets?
Hello,
I have a question and I hope I'll be able to get some help from the list.
Most of the SOAP examples that I have seen and worked with so far use RPC to connect to SOAP server as:
---------------start - RPC-----------------------
import org.apache.soap.rpc.*;
URL url = new URL("http://genx:80/soap/servlet/rpcrouter");
Call call = new Call();
call.setTargetObjectURI("urn:XcelXmlServer");
call.setMethodName("getMeaning");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector();
params.addElement (new Parameter ("wordToLookup", String.class, "toughWord", null));
call.setParams(params);
Response resp = call.invoke(url, "");
Fault fault = resp.getFault();
System.out.print (result.getValue());
---------------end - RPC -----------------------------
But, I need to use sockets instead:
---------------start - Socket -----------------------------
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
String host = "genx"; int port = 80;
String submitURL = "/soap/servlet/rpcrouter";
sslSocket = (SSLSocket)factory.createSocket(host, port);
sslSocket.startHandshake();
socket = new Socket(host, port);
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));
out.println("POST " + submitURL + " HTTP/1.1");
out.println("Host: " + host);
out.println("Content-Type: text/xml");
out.println("Content-Length: " + "toughWord".length());
out.println("SOAPAction: \"\"" + "\n");
out.println(SOAP_HEADER + "\n" + toughWord + "\n" + SOAP_FOOTER);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
socket.close();
---------------end - Socket -----------------------------
I have implemented service 'Dictionary' that has a method 'getMeaning'. I can access it via RPC but not via sockets. The values in the above code snippet are the exact values that I am using in my program.
My question is: Where (and how) in sockets do I specify the equivalent of
call.setTargetObjectURI("urn:XcelXmlServer");
call.setMethodName("getMeaning");
Thanks
Nishi
---------------------------------
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
Re: How to pass params to SOAP server using sockets?
Posted by Scott Nichol <sn...@scottnichol.com>.
I have to ask: why do you need to work directly with sockets? Do you have some requirement that you cannot use a SOAP library?
To answer your questions, the targetObjectURI is the namespace for the service, which effectively means it is the namespace of the method element. That gets to your second question, the setMethodName is specifying the name of the method element.
Your SOAP payload should look something like
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:getMeaning xmlns:ns1="urn:XcelXmlServer"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<wordToLookup xsi:type="xsd:string">toughWord</wordToLookup>
</ns1:getMeaning>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Scott Nichol
Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message -----
From: "Kapoor, Nishikant" <ni...@xcelenergy.com>
To: <so...@ws.apache.org>
Sent: Thursday, December 11, 2003 1:02 PM
Subject: How to pass params to SOAP server using sockets?
Hello,
I have a question and I hope I'll be able to get some help from the list.
Most of the SOAP examples that I have seen and worked with so far use RPC to connect to SOAP server as:
---------------start - RPC-----------------------
import org.apache.soap.rpc.*;
URL url = new URL("http://genx:80/soap/servlet/rpcrouter");
Call call = new Call();
call.setTargetObjectURI("urn:XcelXmlServer");
call.setMethodName("getMeaning");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector();
params.addElement (new Parameter ("wordToLookup", String.class, "toughWord", null));
call.setParams(params);
Response resp = call.invoke(url, "");
Fault fault = resp.getFault();
System.out.print (result.getValue());
---------------end - RPC -----------------------------
But, I need to use sockets instead:
---------------start - Socket -----------------------------
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
String host = "genx"; int port = 80;
String submitURL = "/soap/servlet/rpcrouter";
sslSocket = (SSLSocket)factory.createSocket(host, port);
sslSocket.startHandshake();
socket = new Socket(host, port);
out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())));
out.println("POST " + submitURL + " HTTP/1.1");
out.println("Host: " + host);
out.println("Content-Type: text/xml");
out.println("Content-Length: " + "toughWord".length());
out.println("SOAPAction: \"\"" + "\n");
out.println(SOAP_HEADER + "\n" + toughWord + "\n" + SOAP_FOOTER);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
socket.close();
---------------end - Socket -----------------------------
I have implemented service 'Dictionary' that has a method 'getMeaning'. I can access it via RPC but not via sockets. The values in the above code snippet are the exact values that I am using in my program.
My question is: Where (and how) in sockets do I specify the equivalent of
call.setTargetObjectURI("urn:XcelXmlServer");
call.setMethodName("getMeaning");
Thanks
Nishi