Forum: Ruby SOAP how to make a request

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mario R. (Guest)
on 2009-04-30 19:27
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. :)
Mark T. (Guest)
on 2009-04-30 21:40
(Received via mailing list)
On Apr 30, 11:27 am, Mario R. <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-w...

-- Mark.
Mario R. (Guest)
on 2009-05-04 14:07
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> wrote:
>>
>> � � � � �</ser:loginMethodDTO>
Mario R. (Guest)
on 2009-05-06 14:02
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.
>
Mario R. (Guest)
on 2009-05-08 14:17
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>


Mario R. wrote:
> I was taking a look at the request using a tcp listener and there is
This topic is locked and can not be replied to.