SOAP how to make a request

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:loginNamemyUser</ser:loginName>
ser:passwordmyPwd</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. :slight_smile:

On Apr 30, 11:27 am, Mario R. [email protected] wrote:

     </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. :slight_smile:

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.

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?

Mark T. wrote:

On Apr 30, 11:27�am, Mario R. [email protected] wrote:

� � � � �</ser:loginMethodDTO>

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

Any idea?

Mario R. wrote:

Thanks for the answer.

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=“XML Schema
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:loginNamemyUser</ser:loginName>
ser:passwordmyPwd</ser:password>
</ser:loginMethodDTO>
</ser:loginCustomer>
</soapenv:Body>
</soapenv:Envelope>

Mario R. wrote:

I was taking a look at the request using a tcp listener and there is