SOAP how to make a request

M

Mario Ruiz

Hi, I'm newbie sorry
I'm testing a web service, loginCustomer but I don't know why always
returns... failed to login user. This is my code:

require "soap/wsdlDriver"
WSDL_URL = "http://myserver/WS/services/Access?wsdl"
service = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver

service.generate_explicit_type = true
service.wiredump_dev = STDOUT if $DEBUG

query="
<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:ser='http://myserver.com/WS/services'>
<soapenv:Header/>
<soapenv:Body>
<ser:loginCustomer>
<ser:loginMethodDTO>
<ser:loginName>myUser</ser:loginName>
<ser:password>myPwd</ser:password>
</ser:loginMethodDTO>
</ser:loginCustomer>
</soapenv:Body>
</soapenv:Envelope>
"
result = service.loginCustomer(query)


The xml is working on another client I'm using so this is not the
problem.

Thanks in advance. :)
 
M

Mark Thomas

Hi, I'm newbie sorry
I'm testing a web service, loginCustomer but I don't know why always
returns... failed to login user. This is my code:

require "soap/wsdlDriver"
WSDL_URL = "http://myserver/WS/services/Access?wsdl"
service = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver

service.generate_explicit_type = true
service.wiredump_dev = STDOUT if $DEBUG

query="
<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:ser='http://myserver.com/WS/services'>
   <soapenv:Header/>
   <soapenv:Body>
      <ser:loginCustomer>
         <ser:loginMethodDTO>
            <ser:loginName>myUser</ser:loginName>
            <ser:password>myPwd</ser:password>
         </ser:loginMethodDTO>
      </ser:loginCustomer>
   </soapenv:Body>
</soapenv:Envelope>
"
result = service.loginCustomer(query)

The xml is working on another client I'm using so this is not the
problem.

Thanks in advance. :)

This doesn't look right. Usually, you don't hand-code a string
containing SOAP XML and call SOAP4R methods with it. The purpose of
SOAP4R is to shield you from all that.

It's hard to tell exactly without the WSDL, but my guess is that what
you really want is something like
result = service.loginCustomer('user','pass').

Have you tried generating a sample client? See
http://markthomas.org/2007/09/12/getting-started-with-soap4r/

-- Mark.
 
M

Mario Ruiz

Thanks for the answer.

It's a little bit more complicated in my case.
the wsdl is:
<xs:element name="loginCustomer">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="loginMethodDTO" nillable="true"
type="ajs:LoginRequestDTO" />
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:complexType name="LoginRequestDTO">
<xs:complexContent>
<xs:extension base="ajs:ajDTO">
<xs:sequence>
<xs:element minOccurs="0" name="loginName" nillable="true"
type="xs:string" />
<xs:element minOccurs="0" name="password" nillable="true"
type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

<wsdl:message name="loginCustomerRequest">
<wsdl:part name="parameters" element="ajs:loginCustomer" />
</wsdl:message>

do you need to know anything else?
 
M

Mario Ruiz

I was taking a look at the request using a tcp listener and there is
nothing on the loginMethodDTO.

Any idea?
 
M

Mario Ruiz

I made a mistake there is no loginMethodDTO xml tag on the request but
should be.
The request that soap4r is sending is:

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:loginCustomer xmlns:n1="http://betware.com/WS/services">
<n1:loginRequest>
</n1:loginRequest>
</n1:loginCustomer>
</env:Body>
</env:Envelope>

and should be something like:

<soapenv:Envelope
xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'
xmlns:ser='http://myserver.com/WS/services'>
<soapenv:Header/>
<soapenv:Body>
<ser:loginCustomer>
<ser:loginMethodDTO>
<ser:loginName>myUser</ser:loginName>
<ser:password>myPwd</ser:password>
</ser:loginMethodDTO>
</ser:loginCustomer>
</soapenv:Body>
</soapenv:Envelope>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top