# SOAP how to make a request

**URL:** <https://www.ruby-forum.com/t/soap-how-to-make-a-request/166894>\
**Category:** Ruby\
**Created:** [April 30, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/soap-how-to-make-a-request/166894 "2009-04-30T17:27:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 30, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/soap-how-to-make-a-request/166894/1 "2009-04-30T17:27:35Z")

</div>

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](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/](http://schemas.xmlsoap.org/soap/envelope/)’  
xmlns:ser=‘[http://myserver.com/WS/services](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. 🙂

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [April 30, 2009, 7:40pm UTC](https://www.ruby-forum.com/t/soap-how-to-make-a-request/166894/2 "2009-04-30T19:40:50Z")

</div>

On Apr 30, 11:27 am, Mario R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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. 🙂

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/](http://markthomas.org/2007/09/12/getting-started-with-soap4r/)

– Mark.

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [May 4, 2009, 12:07pm UTC](https://www.ruby-forum.com/t/soap-how-to-make-a-request/166894/3 "2009-05-04T12:07:16Z")

</div>

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. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ï¿½ ï¿½ ï¿½ ï¿½ ï¿½\</ser:loginMethodDTO\>

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [May 6, 2009, 12:02pm UTC](https://www.ruby-forum.com/t/soap-how-to-make-a-request/166894/4 "2009-05-06T12:02:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tcblues](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/db5fbb/32.png) [@tcblues](https://www.ruby-forum.com/u/tcblues)\
**Post date:** [May 8, 2009, 12:17pm UTC](https://www.ruby-forum.com/t/soap-how-to-make-a-request/166894/5 "2009-05-08T12:17:33Z")

</div>

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](http://www.w3.org/2001/XMLSchema)”  
xmlns:env=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”\>  
env:Body  
\<n1:loginCustomer xmlns:n1=“[http://betware.com/WS/services](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/](http://schemas.xmlsoap.org/soap/envelope/)’  
xmlns:ser=‘[http://myserver.com/WS/services](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
