[SoapRMI] Re: _how_to_call_apache-soap_

Aleksander Slominski aslom_at_cs.indiana.edu
Tue, 10 Dec 2002 13:07:36 -0500


the problem is with parameter name, Apache expects it to be "box" as 
XSOAP sends "sayHello", seE:

<box xsi:type="xsd:string">ste</box>
<sayHello xsi:type='xsd:string'>steve</sayHello>


use this to modify parameter name (i have not tested it but it should be 
OK):

       XmlJavaMapping mapping = soaprmi.soap.Soap.getDefault().getMapping();
       mapping.setDefaultStructNsPrefix(null); // disable XSOAP auto mapping
       fixNames(mapping);

        public static void fixNames(XmlJavaMapping mapping) throws 
Exception {

                XmlJavaPortTypeMap portMap = 
mapping.queryPortType(HelloClient.class);

                // extract mapping for operation
                XmlJavaOperationMap oMap 
=portMap.queryMethodRequest("sayHello");

                // get in message and change part names
                XmlJavaMessageMap requestMsg = oMap.getRequest();
                XmlJavaPartMap[] reqParts = requestMsg.getParts();
                reqParts[0].setPartName("box");

                //oMap =portMap.queryMethodRequest("anotherMethod");
                // get in message and change part names
                //requestMsg = oMap.getRequest();
                //reqParts = requestMsg.getParts();
                //reqParts[0].setPartName("parmaeter1Name");
                //reqParts[1].setPartName("parameter2Namee");
        }

let me know if it solved the problem.

thanks,

alek

nodep_at_libero.it wrote:

>Hi,
>the code I used is in the attachment file. It's
>the minimal sample for the XSOAP side and a simple
>HelloWorld service for Apache-soap. First, I report
>the output of Apache-Soap message when I call the service:
>
>POST /soap/servlet/rpcrouter HTTP/1.0
>Host: localhost:8080
>Content-Type: text/xml; charset=utf-8
>Content-Length: 441
>SOAPAction: ""
>
><?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:sayHello xmlns:ns1="urn:HelloWorld" SOAP-
>ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
><box xsi:type="xsd:string">ste</box>
></ns1:sayHello>
></SOAP-ENV:Body>
></SOAP-ENV:Envelope>
>
>
>and the return is:
>
>HTTP/1.1 200 OK
>Set-Cookie: JSESSIONID=16B1353B36CD54CA2EFF3C26B77BAC75; Path=/soap
>Content-Type: text/xml; charset=utf-8
>Content-Length: 489
>Date: Tue, 10 Dec 2002 17:59:29 GMT
>Server: Apache Coyote/1.0
>Connection: close
>
><?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:sayHelloResponse xmlns:ns1="urn:HelloWorld" SOAP-
>ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
><return xsi:type="xsd:string">Hello! Welcome to SOAP,steve.</return>
></ns1:sayHelloResponse>
>
></SOAP-ENV:Body>
></SOAP-ENV:Envelope>
>
>
>Now, I've created an interface of the Apache-soap service and
>placed it in the minimal sample directory and I've modified
>HelloClient.java so that it shoulds to call Apache-soap's service.
>The output of Xsoap is:
>
>POST / HTTP/1.0
>Host: localhost
>User-Agent: SoapRMI/1.2
>Content-Type: text/xml; charset=utf-8
>Content-Length: 459
>SOAPAction: ""
>Connection: Close
>
><SOAP-ENV:Envelope xmlns:SOAP-
>ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-
>ENC='http://schemas.xmlsoap.org/soap/encoding/' 
>xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance' 
>xmlns:xsd='http://www.w3.org/1999/XMLSchema' 
>SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
>
><SOAP-ENV:Body>
>
><m:sayHello xmlns:m='urn:HelloWorld'>
>
><sayHello xsi:type='xsd:string'>steve</sayHello>
>
></m:sayHello>
>
></SOAP-ENV:Body>
>
></SOAP-ENV:Envelope>
>
>
>but the result is this error:
>
>F:\J\xsoap\minimal>java minimal.HelloClient http://localhost:8080 steve
>Client executing remote method sayHello on server with 'steve' argument
>Exception in thread "main" soaprmi.RemoteException: Envelope start tag 
>expected
>not html at line 1 and column 6 seen <html>... (parser state START_TAG)
>        at soaprmi.soaprpc.MethodInvoker.receiveResponse
>(MethodInvoker.java:344)
>
>        at 
>soaprmi.soaprpc.HttpSocketSoapInvocationHandler.invokeTransport(HttpS
>ocketSoapInvocationHandler.java:133)
>        at soaprmi.soaprpc.SoapDynamicStub.invoke
>(SoapDynamicStub.java:118)
>        at $Proxy0.sayHello(Unknown Source)
>        at minimal.HelloClient.main(HelloClient.java:69)
>
>
>I see that there're differences beetwen the output's messages
>but I don't know why (i.e. "<ns1:sayHello ..." and "<m:sayHello ...", 
>or the position
>of SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/")
>Could you help me?
>Thanks!
>
>Stefano Pedon
>
>PS-I use Apache-soap v2.3.1, is it the same of Axis?
>
>  
>
>>nodep_at_libero.it wrote:
>>
>>    
>>
>>>Hi Alek,
>>>I've to call an Apache-soap
>>>      
>>>
>(v2.3.1) service is running on Tomcat server,
>  
>
>>>could you tell me the basic setting, please? (In the xsoap-
>>>      
>>>
>side ... :))
>  
>
>>>Here is the "Deployed Service Information" as is in "Apache SOAP Adm
>>>      
>>>
>in":
>  
>
>>>'urn:HelloWorldServer' Service Deployment Descriptor
>>>Property 			Details
>>>
>>>ID urn:				HelloWorldServer
>>>Scope 				Request
>>>Provider Type 			java
>>>Provider Class 		
>>>      
>>>
>	esempi.helloworld.HelloWorldServer
>  
>
>>>Use Static Class 		false
>>>Methods 			sayHello
>>>Type Mappings
>>>Default Mapping Registry Class
>>> 
>>>
>>>      
>>>
>>hi,
>>
>>take a look on  on samples/interop/client/Main.java in this case
>>you just need to create startpoint that points to server interface
>>i assume here that server HelloWorldServer implement HelloWorld
>>interface that has sayHello method and is running at 
>>http://localhost:8080/axis/services/hello)
>>
>>    HelloWorld serverReference = HelloWorld)
>>            soaprmi.soaprpc.SoapServices.getDefault
>>    
>>
>().createStartpoint(
>  
>
>>            //server location,
>>            new Class[]{HelloWorld .class},
>>            "HelloWorldServer" // service namespace in case of AXIS i
>>    
>>
> 
>  
>
>>think it is ID urn,
>>            soaprmi.soap.SoapStyle.SOAP11,
>>            "" // soapAction
>>        );
>>
>>let me know if it worked OK fro you (or if not i will need to know mo
>>    
>>
>re
>  
>
>>about server setup what is exactly HelloWorldServer and how AXIS clie
>>    
>>
>nt 
>  
>
>>looks).
>>
>>thanks,
>>
>>alek
>>
>>-- 
>>The ancestor of every action is a thought. - Ralph Waldo Emerson 
>>
>>
>>    
>>

-- 
The ancestor of every action is a thought. - Ralph Waldo Emerson