[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

SOAP how to make a request

Mario Ruiz

4/30/2009 3:28:00 PM

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/enve...
xmlns:ser='http://myserver.com/WS/service...
<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. :)
--
Posted via http://www.ruby-....

4 Answers

Mark Thomas

4/30/2009 5:39:00 PM

0

On Apr 30, 11:27 am, Mario Ruiz <ma...@betware.com> wrote:
> 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/enve...
> xmlns:ser='http://myserver.com/WS/service...
>    <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-wi...

-- Mark.

Mario Ruiz

5/4/2009 10:07:00 AM

0

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 Thomas wrote:
> On Apr 30, 11:27�am, Mario Ruiz <ma...@betware.com> wrote:
>>
>> � � � � �</ser:loginMethodDTO>
--
Posted via http://www.ruby-....

Mario Ruiz

5/6/2009 10:03:00 AM

0

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

Any idea?

Mario Ruiz wrote:
> Thanks for the answer.
>
--
Posted via http://www.ruby-....

Mario Ruiz

5/8/2009 10:18:00 AM

0

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/XMLSc...
xmlns:env="http://schemas.xmlsoap.org/soap/envel...
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/enve...
xmlns:ser='http://myserver.com/WS/service...
<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 Ruiz wrote:
> I was taking a look at the request using a tcp listener and there is
--
Posted via http://www.ruby-....