[SoapRMI] solved :-) [Re: _how_to_call_apache-soap_]

Aleksander Slominski aslom_at_cs.indiana.edu
Tue, 10 Dec 2002 21:06:43 -0500


hi Stefano,

i have looked agin on traces and found what is the problem!

in XSOAP whn you contact service you do not need ot specify complete 
path if it is only one service but this is not case for AXIS. if you 
look on both traces (below) you will see that when you use XSOAP your 
URL has only "/" but for Apache AXIS client you have 
"/soap/servlet/rpcrouter"

so make sure that XSOAP HelloClient uses argument 
http://localhost:8080/soap/servlet/rpcrouter and it should just work 
fine ;-) .

alek

AXIS client:

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>


XSOAP client:

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>


nodep_at_libero.it wrote:

>Hi Alek,
>I modified "HelloClient.java" with your code but it doesn't works :(
>I've attached the source. It sends:
>
>POST / HTTP/1.0
>Host: localhost
>User-Agent: SoapRMI/1.2
>Content-Type: text/xml; charset=utf-8
>Content-Length: 449
>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'>
>
>  <box xsi:type='xsd:string'>steve</box>
>
> </m:sayHello>
>
></SOAP-ENV:Body>
>
></SOAP-ENV:Envelope>
>
>
>but I've got the error:
>
>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:75)
>
>Difference from Apache-soap message is:
>
><m:sayHello xmlns:m='urn:HelloWorld'>
>
>Vs
><ns1:sayHello xmlns:ns1="urn:HelloWorld" SOAP-
>ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
>
>but: is it very important?(the place where is "SOAP-
>ENV:encodingStyle=....")
>
>Thanks!
>
>Stefano Pedon
>
>PS-In your original code you wrote "HelloClient.class" 
>   but I've corrected with "HelloWorldServer.class": it's ok?
>
>
>
>  
>
>>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 st
>>>      
>>>
>eve
>  
>
>>>Client executing remote method sayHello on server with 'steve' argum
>>>      
>>>
>ent
>  
>
>>>Exception in thread "main" soaprmi.RemoteException: Envelope start t
>>>      
>>>
>ag 
>  
>
>>>expected
>>>not html at line 1 and column 6 seen <html>... (parser state START_T
>>>      
>>>
>AG)
>  
>
>>>       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 A
>>>>>          
>>>>>
>dm
>  
>
>>>>>     
>>>>>
>>>>>          
>>>>>
>>>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 cl
>>>>        
>>>>
>ie
>  
>
>>>>   
>>>>
>>>>        
>>>>
>>>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 
>>
>>
>>    
>>

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