You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Kumaresan, Karikalan" <Ka...@mybau.com> on 2001/10/31 18:45:25 UTC
Getting client SOAP request XML...
> Hi,
>
> I have created the SOAP client as follows...
>
> public class SOAPXMLUpload
> {
>
> public static String uploadXML( String routerURL,
> String fileName,
> String userName,
> String password,
> String urn ) throws Exception
> {
> //Get the SOAP router URL
> URL url = new URL( routerURL );
>
> //Read the content from file
> FileInputStream in = new FileInputStream( fileName );
> byte[] fromFile = new byte[ in.available() ];
> in.read( fromFile );
> //Convert bytes to string, encode if necessary
> String xmlData = new String( fromFile );
>
> //Build the SOAP call
> Call call = new Call();
>
> 1. //call.setSOAPTransport( new
> org.apache.soap.transport.http.SOAPHTTPConnection() );
>
> call.setSOAPMappingRegistry(new SOAPMappingRegistry());
> call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
> call.setTargetObjectURI( urn );
> call.setMethodName("dispatchXML");
>
> //Set the parameter
> Vector params=new Vector();
> params.addElement(new Parameter("userName", String.class, userName,
> null));
> params.addElement(new Parameter("password", String.class, password,
> null));
> params.addElement(new Parameter("xmlData", String.class, xmlData,
> null));
> call.setParams(params);
>
> 2. //Call.getEnvelopeString( call.getSOAPTransport() );
>
>
>
> //Invoke the call to the SOAP server
> Response resp = call.invoke(url,"");
>
> //Get the reply from the servlet
> boolean status = resp.generatedFault();
> Parameter ret = resp.getReturnValue();
> System.out.println( "ret = " + ret );
>
> String retString = "";
> if( ret != null )
> {
> retString = ret.toString() + " ";
> retString += (String)ret.getValue();
> }
>
> //Return the reply string
> return retString;
> }
> }
>
> The program is working fine.
> I am not using the SOAP Envelope XML here, everything would be taken care
by
> the client itself.
>
> Now.. I want to print the "request SOAP Envelope string" in the screen. I
> have used the lines which is marked as 1 & 2 in the above progam. But if I
> use that, in the second line I am getting the NullpointerException.
>
> Could you please let me know how to get the request SOAP Envelope string
in
> this case?
>
> Thanks a lot...
>
> regards,
> Karikalan