The "return value" is the first element in the response, which in this case
is 'login'.  The other elements in the response are available in the
Response#getParams, which returns a Vector of Parameter instances.

Scott Nichol

----- Original Message -----
From: "Siddique Farhan-W13881" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 02, 2002 4:27 PM
Subject: RE: SOAPException


Hi Scott,
Let me tell you what I am trying to do, I am trying to write a Java
based SOAP client to get service from a remote web service. The SOAP request
envelop is as follows

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/";
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/1999/XMLSchema";>
<SOAP-ENV:Body>
<namesp1:chargeRequest xmlns:namesp1="http://102.108.132.3:8000/DoneHere";>
<login xsi:type="xsd:string">testuser</login>
<password xsi:type="xsd:string">testpassword</password>
<priceclass xsi:type="xsd:string">100</priceclass>
</namesp1:chargeRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

and SOAP response is as follows

<namesp13:chargeRequestResponse
xmlns:namesp13="http://102.108.132.3:8000/DoneHere";>
                <login xsi:type="xsd:string">testuser</login>
                <usertype xsi:type="xsd:string">genion</usertype>
                <resultcode xsi:type="xsd:string">0641</resultcode>
                <resultmessage xsi:type="xsd:string">Request
OK.</resultmessage>
        </namesp13:chargeRequestResponse>

My code is as follows

public class Client{

    public static String chargeRequest (URL url, String proxyUri, String
login,
String password,  String priceclass) throws Exception {


// Instantiate the SOAP call
        Call call = new Call ();

// Service uses standard SOAP encoding
        String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
// Set standard SOAP Encoding
    call.setEncodingStyleURI(encodingStyleURI);

// Instantiate SOAP mapping for xsi:type attribute

        SOAPMappingRegistry smr = new SOAPMappingRegistry();
        StringDeserializer sd = new StringDeserializer();

// Set the SOAP mapping for xsi:type return attribute
          smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("", "login"),
null,
null, sd);
         smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("", "usertype"),
             null, null, sd);
          smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("",
"resultcode"),
             null, null, sd);
          smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("",
"resultmessage"),
             null, null, sd);
    call.setSOAPMappingRegistry(smr);

// Set service locator parameters
    call.setTargetObjectURI (proxyUri);
// Set target method name
        call.setMethodName ("chargeRequest");

// Create input parameter vector
        Vector params = new Vector ();
    params.addElement (new Parameter("login", String.class, login, null));
    params.addElement(new Parameter("password",String.class,transid,null))
    params.addElement (new Parameter("priceclass", String.class, priceclass,
null));

        call.setParams (params);

System.out.println("Calling"+params);

// Invoke the billing interface service ....
        org.apache.soap.rpc.Response resp = call.invoke(url,"");

// Evaluate the response
        if (resp.generatedFault ()) {
System.out.println("No Success");
            throw new Exception();
        } else {
          // Call was successful. Extract response parameter and return
result
            Parameter result = resp.getReturnValue ();
            return (String) result.getValue();

        }
    }
// Sample Service invocation
    public static void main(String[] args)
    {
    try
        {
            String proxyUrl = "http://102.108.132.3:8000/DoneHere";;
            URL url = new URL("http://102.108.132.3:8000/Dhere.pl";);
            String login= "testuser";
            String password = "testpassword";
            String priceclass = "100";
            System.out.println("Calling chargeRequest");
billinfo =
chargeRequest(url,proxyUrl,login,password,priceclass);
System.out.println(billinfo);
        }
    catch (Exception e) {e.printStackTrace();}
    }
}


I am not getting any faults, the call is successful. But, unable to extract
the resultcode attribute. What am I doing wrong here. Maybe I am too tired.
Thanks for your answer in advance.

Regards,

Farhan

-----Original Message-----
From: Scott Nichol [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 02, 2002 1:47 PM
To: [EMAIL PROTECTED]
Subject: Re: SOAPException


You will get the most help from this list if you post the code you are
trying to run.  Otherwise, unless you are experiencing one of the more
common problems, you will probably not provide enough information for the
folks reading this list to help.

Scott Nichol

----- Original Message -----
From: "Siddique Farhan-W13881" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 02, 2002 12:59 PM
Subject: RE: SOAPException


Hi Guys,
I am getting a different error now. What can be wrong if i get this
error
java.lang.Exception
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.fillInStackTrace(Compiled Code)
        at java.lang.Throwable.<init>(Compiled Code)
        at java.lang.Exception.<init>(Compiled Code)

-----Original Message-----
From: Siddique Farhan-W13881 [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 4:29 PM
To: [EMAIL PROTECTED]
Subject: RE: SOAPException


Scott:
The java client is not using a proxy for the HTTP connection. I am
not sure about the Web service that is hosted at the server side. Its a
SOAP::Lite implementation. I went through the Perl SOAP::lite tutorial at
http://www.xmethods.com/gettingstarted/soaplite.html and interpreted that
the TargetObjectURI as the String provided to the URI object in Perl code. I
have no clue, any ideas??
Thanks for responding,
Regards,

Farhan

-----Original Message-----
From: Scott Nichol [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 4:21 PM
To: [EMAIL PROTECTED]
Subject: Re: SOAPException


To use a proxy, you should create a SOAPHTTPConnection, set the proxy values
(e.g. setProxyHost, setProxyPort), then set the transport on your Call with
setSOAPTransport.  The URL for your invoke should be the URL of the service,
not the proxy.  Also, the TargetObjectURI is probably not the URL of the
service.  The samples commonly use a urn:xxxx.

Scott Nichol

----- Original Message -----
From: "Siddique Farhan-W13881" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 01, 2002 4:20 PM
Subject: SOAPException


Hi Guys,
I am trying to convert a SOAP client written in Perl to Java and I
am getting a SOAP-Exception at run-time.

Code snippet for connection in Perl is like this

$soap_response = SOAP::Lite -> uri('http://100.100.100.100:8000/DoneHere')
        ->
proxy('http://100.100.100.100:8000/exect.pl')
                                            -> methodToExecute;

Part of my java code is like this

String proxyUri = "http: // 100.100.100.100:8000/DoneHere";
URL url = new URL("http://100.100.100.100.100:8000/exect.pl";);


call.setTargetObjectURI (proxyUri);  //uri is a String
call.setMethodName ("methodToExecute");
org.apache.soap.rpc.Response resp = call.invoke(url,"");


The SOAP exeption I am getting is like this

[SOAPException: faultCode=SOAP-ENV:Client; msg=Connection reset by peer:
Connect
ion reset by peer; targetException=java.net.SocketException: Connection
reset by
 peer: Connection reset by peer]
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.fillInStackTrace(Compiled Code)
        at java.lang.Throwable.<init>(Compiled Code)
        at java.lang.Exception.<init>(Exception.java:42)
        at org.apache.soap.SOAPException.<init>(SOAPException.java:71)
        at org.apache.soap.SOAPException.<init>(SOAPException.java:77)
        at
org.apache.soap.transport.http.SOAPHTTPConnection.send(SOAPHTTPConnec
tion.java:328)
        at org.apache.soap.rpc.Call.invoke(Call.java:205)


Is there something I am missing?? Please help. Thanks

Regards,

Farhan


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to