You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by "Ding, Chengmin" <Ch...@tfn.com> on 2001/10/25 01:31:51 UTC

question about encodingStyle

Hi, Soap Folks,
The following program always return the error message: 

D:\java\apache\samples\hello>java samples.hello.HelloC
invoke service
  URL= http://localhost:8181/soap/servlet/rpcrouter
  URN =urn:demo1:hello
SOAPException= SOAP-ENV:Client, I only know how to serialize an
'org.w3c.dom.Ele
ment'.

I want to know why I cannot use the Literal Encoding for it while SOAP_ENC
works fine.

Besides, if I use a VB client, the encodingstyle is at the Envelop Level.
<SOAP-ENV:Envelope
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body>
if I use a Java client(Apache Soap), the encodingstyle is at the method
level.
<ns1:SayHello xmlns:ns1="urn:demo1:hello"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
My service is written in Apache Soap, will it recognize the correct
encodingStyle if the request is from a VB client? 

Thank you in advance.

-Chengmin


=================================================================
package samples.hello;
import java.net.*; 
 import java.util.*; 
 import org.apache.soap.*; // Body, Envelope, Fault, Header 
 import org.apache.soap.rpc.*; // Call, Parameter, Response 

 public class HelloC 
   { 
   public static void main( String[] args ) throws Exception 
     { 
     //URL url = new URL( "http://localhost:8080/soap/servlet/rpcrouter" ); 
     URL url = new URL( "http://localhost:8181/soap/servlet/rpcrouter" ); 
     String urn = "urn:demo1:hello"; 
     String sName = "World";
     if (args.length> 0)
         sName = args[0];	
     Call call = new Call(); // prepare the service invocation 
     call.setTargetObjectURI( urn ); 
     call.setMethodName( "SayHello" ); 
     //call.setEncodingStyleURI( Constants.NS_URI_SOAP_ENC ); 
     //call.setEncodingStyleURI( Constants.NS_URI_LITERAL_XML ); 
     //call.setEncodingStyleURI( Constants.NS_URI_SCHEMA_XSD ); 
     Vector params = new Vector(); 
     params.addElement( new Parameter( "sName", String.class, sName,
Constants.NS_URI_LITERAL_XML ) ); 
     call.setParams( params ); 

     try 
       { 
       System.out.println( "invoke service\n" + "  URL= " + url + "\n  URN
=" + 
          urn ); 
       Response response = call.invoke( url, "" ); // invoke the service 

       if( !response.generatedFault() ) 
         { 
         Parameter result = response.getReturnValue(); // response was OK 
         System.out.println( "Result= " + result.getValue() ); 
         } 
       else 
         { 
         Fault f = response.getFault(); // an error occurred 
         System.err.println( "Fault= " + f.getFaultCode() + ", " + 
           f.getFaultString() ); 
         } 
       } 
     catch( SOAPException e ) // call could not be sent properly 
       { 
       System.err.println( "SOAPException= " + e.getFaultCode() + ", " +  
         e.getMessage() ); 
       } 
     } 
   }