soap4r. I just dont get it.

N

nkb

Hi.

I have tried for a hours but I still cannot get it. What is wrong with
my codes? I keep getting this error
#<SOAP:Mapping::Object:0x2bb0e90>: Fault occurred -->
System.Xml.XmlElement (SOAP::FaultError)

Below is my code to access the webservice. According to the logs from
the webservice server, I am able to access to the webservice. But there
seems to be something wrong in the way I place my input argument.

#######
require 'soap/rpc/driver'

Host = "http://mysite/serviceA/serviceA1.asmx"
NS = "urn:mysite.co.uk:webservices"
client = SOAP::RPC::Driver.new(Host, NS)
client.add_method_with_soapaction('mygetData', 'getData', 'dataID')
p client.mygetData(1)
#######

And this is the webservice statements from the server. It says this is
how I should form my soap request.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getData xmlns="urn:mysite.co.uk:webservices">
<DataID>int</DataID>
<inputstring>
<string>string</string>
<string>string</string>
</inputstring>
</getData>
</soap:Body>
</soap:Envelope>
 
N

NAKAMURA, Hiroshi

Hi,

I have tried for a hours but I still cannot get it. What is wrong with
my codes? I keep getting this error
#<SOAP:Mapping::Object:0x2bb0e90>: Fault occurred -->
System.Xml.XmlElement (SOAP::FaultError)

Do you have the WSDL for the service you want to connect with?

If you don't... try below.
Below is my code to access the webservice. According to the logs from
the webservice server, I am able to access to the webservice. But there
seems to be something wrong in the way I place my input argument.

#######
require 'soap/rpc/driver'

Host = "http://mysite/serviceA/serviceA1.asmx"
NS = "urn:mysite.co.uk:webservices"
client = SOAP::RPC::Driver.new(Host, NS)
client.add_method_with_soapaction('mygetData', 'getData', 'dataID')

client.add_method_with_soapaction('getData',
"soapactionthattheserverrequires", 'DataID', "inputstring")
client.generate_explicit_type = false
p client.mygetData(1)

p client.getData(5, ["string1", "string2"])

It should send a request as follows:

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:getData xmlns:n1="foo">
<DataID>5</DataID>
<inputstring>
<item>string1</item> <== XXX
<item>string2</item> <== XXX
</inputstring>
</n1:getData>
</env:Body>
</env:Envelope>

The server may not accept the request because of the element name at
XXX part above does not match with expected one (<string>). Then you
need WSDL.

Regards,
// NaHi
 
J

Justin Rudd

What is the Fault that the server is giving you? You should be able
to access the SOAP:faultstring or SOAP:detail. Since it is an ASP.NET
Web Service, you should go into the web.config file and turn off
custom errors. This way ASP.NET will return the callstack that it
generated on the error. Then you can see what the exact error is. My
guess is that you are missing parameters or accessing elements that
really aren't there (maybe a string array and you are getting an index
out of bounds exception).

The ASP.NET Web Services engine is very liberal in what it accepts.
It won't error if you send it info that it doesn't understand and it
won't error if you DON'T send it info that is required.
The server may not accept the request because of the element name at
XXX part above does not match with expected one (<string>). Then you
need WSDL.

It will accept the request. But it will ignore what it doesn't understand.

You can get the WSDL by adding the query string ?WSDL. Hopefully
soap4r will understand the WSDL spit out :) I've stopped using
ASP.NET auto generated WSDL. I find it easier to write it by hand.
 
N

nkb

Thanks for the prompt reply.

client.generate_explicit_type statement generate an error
undefined method 'generate_explicit_type=' for
#<SOAP::RPC::Driver:0x2830c08> (NoMethodError)

So I commented it out but still receives the same error
#<SOAP::Mapping::Object:0x2ba5268>: Fault occurred -->
System.Xml.XmlElement (SOAP::FaultError)

I wonder if I should just skip the soap4r and simply use ruby to do a
simple http post with my own soap content? Would this be not adviable?
Many thanks!!
 
N

nkb

ya. I did check the server error. It says Data Does not exist. Which I
suppose means I'm sending some wrong arguments over. There is a switch
case in the .net codes and in the switch case, it default to such error
when the input arugment is not correct.
By the way, why do I need WSDL? What does it mean that I need WSDL? I
thought all web services would have some form of WSDL isnt it? Anyway, I
can read the WSDL from the internet explorer. Is that enough?

Justin Rudd wrote on 2004/09/22 15:37:
 
J

Justin Rudd

By the way, why do I need WSDL? What does it mean that I need WSDL? I
thought all web services would have some form of WSDL isnt it? Anyway, I
can read the WSDL from the internet explorer. Is that enough?

Without going into a lot of detail, the WSDL is the contract. It
describes services (objects) and ports (methods). The ports are what
you send across the wire.

Given the WSDL, you can feed it into WSDL4R (or maybe even at runtime)
and get Ruby code that will "do the right thing" on the wire including
element names. My guess is your ASMX file (or the code-behind) has a
method like so (can't infer the return type from what you posted) -

GetData(int DataID, string[] inputstring)

If you are validating that there are elements in inputstring, the way
you are sending them (and the first answer you received) won't work
because you need to pass in the array of items. And ASP.NET is very
specific in what it is looking for. It will be looking for the
fragment -

<inputstring>
<string>foo</string>
<string>bar</string>
</inputstring>

Anything else will be ignored, but it won't raise an error. Also XML
is case sensitive, make sure the element names going from Ruby to
ASP.NET are spelled correctly including case. I know I've made that
mistake many, many times.

I can't really comment much more because I've not worked with SOAP4R.
I can answer whatever issues you have with ASP.NET though. I've
learned over the years to bend it to my will :)
 
D

David Ross

I might asd well start writing english SOAP
documentation that explains details of soap4r. Where
should I start? I know I should definitely document
where I was having trouble at first.

you are at gmail now, why?

-dross

--- "NAKAMURA said:
Hi,

I have tried for a hours but I still cannot get it. What is wrong with
my codes? I keep getting this error
#<SOAP:Mapping::Object:0x2bb0e90>: Fault occurred -->
System.Xml.XmlElement (SOAP::FaultError)

Do you have the WSDL for the service you want to
connect with?

If you don't... try below.
Below is my code to access the webservice. According to the logs from
the webservice server, I am able to access to the webservice. But there
seems to be something wrong in the way I place my input argument.

#######
require 'soap/rpc/driver'

Host = "http://mysite/serviceA/serviceA1.asmx"
NS = "urn:mysite.co.uk:webservices"
client = SOAP::RPC::Driver.new(Host, NS)
client.add_method_with_soapaction('mygetData',
'getData', 'dataID')

client.add_method_with_soapaction('getData',
"soapactionthattheserverrequires", 'DataID',
"inputstring")
client.generate_explicit_type = false
p client.mygetData(1)

p client.getData(5, ["string1", "string2"])

It should send a request as follows:

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:getData xmlns:n1="foo">
<DataID>5</DataID>
<inputstring>
<item>string1</item> <== XXX
<item>string2</item> <== XXX
</inputstring>
</n1:getData>
</env:Body>
</env:Envelope>

The server may not accept the request because of the
element name at
XXX part above does not match with expected one
(<string>). Then you
need WSDL.

Regards,
// NaHi




_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
 
R

rcoder

Personally, I was unable to get any Ruby SOAP client to work until our
ASP.NET web service was switched to use RPC encoding. After that, I was
able to use the auto-generated WSDL, and the service worked perfectly.

That being said, after trying to hack the SOAP4R library to allow
dynamic configuration of proxy settings, I just gave up, and am now
using basic HTTP GET, and passing my (all string-valued) parameters as
the query string.

Just out of curiosity, are you still calling the service with only one
argument, as in your first example? Have you tried adding an array of
strings to the parameters, to see if the error is actually coming from
that?
 
N

nkb

I am giving up on the soap4r for now. I think it is a great library to
use if I get to have it working (and if there maybe more examples for
the uninitiated like me). But I'm on negative time now, and http happens
to work for me meanwhile. :)
 
N

NAKAMURA, Hiroshi

Hi,

Thank you for great advice about ASP.NET! It much help me to answer
ASP.NET related questions I'll receive.

It will accept the request. But it will ignore what it doesn't understand.
Gee.

You can get the WSDL by adding the query string ?WSDL. Hopefully
soap4r will understand the WSDL spit out :) I've stopped using
ASP.NET auto generated WSDL. I find it easier to write it by hand.

Recent soap4r should understand ASP.NET auto generated WSDL file but I
agree with you that generally it is easy to write by hand.

Regards,
// NaHi
 
N

NAKAMURA, Hiroshi

Hi,

client.generate_explicit_type statement generate an error
undefined method 'generate_explicit_type=' for
#<SOAP::RPC::Driver:0x2830c08> (NoMethodError)

Doh. This API (generate_explicit_type=) is recently added. Can you
try the latest soap4r tarball at http://rrr.jin.gr.jp/download/ ?

Or, please try
client.default_encodingstyle =
SOAP::EncodingStyle::ASPDotNetHandler::Namespace
instead of
client.generate_explicit_type = false

Regards,
// NaHi
 
N

NAKAMURA, Hiroshi

Hi,

I might asd well start writing english SOAP
documentation that explains details of soap4r. Where
should I start? I know I should definitely document
where I was having trouble at first.

Speaking about myself, I don't very often read documents... Generally
I first read sample programs, google sample programs, then write a
sample by myself. The next step is tracing its source code through
debugger. I don't think no documents required, but I cannot imagine
what documents are requied. Maybe do to lack of my English skill.

Soap4r users, how do you think?
you are at gmail now, why?

It has nothing to do about soap4r. I'm just tired of collecting spams
to my job e-mail address (I'm an admin). Gmail filters spams without
my computer/network resource!

Regards,
// NaHi
 
N

NAKAMURA, Hiroshi

Hi,

Personally, I was unable to get any Ruby SOAP client to work until our
ASP.NET web service was switched to use RPC encoding. After that, I was
able to use the auto-generated WSDL, and the service worked perfectly.

For my testing purpose, can I see the WSDL which is not RPC encoding
you failed to use? Ignore this if you think it cannot be. Some WSDL
should be private because of business contract.
That being said, after trying to hack the SOAP4R library to allow
dynamic configuration of proxy settings, I just gave up, and am now
using basic HTTP GET, and passing my (all string-valued) parameters as
the query string.

Would you please explain what "dynamic configuration of proxy setting"
is? Sounds that it should be supported.

Regards,
// NaHi
 
N

NAKAMURA, Hiroshi

Hi,

I am giving up on the soap4r for now. I think it is a great library to
use if I get to have it working (and if there maybe more examples for
the uninitiated like me). But I'm on negative time now, and http happens
to work for me meanwhile. :)

Doh, I should have read this first! Ignore previous mail I asked to try.

Sorry for wasting your time about soap4r. Indeed, soap4r should have
good documents.

Regards,
// NaHi
 
D

David Ross

--- "NAKAMURA said:
Hi,



Speaking about myself, I don't very often read
documents... Generally
I first read sample programs, google sample
programs, then write a
sample by myself. The next step is tracing its
source code through
debugger. I don't think no documents required, but
I cannot imagine
what documents are requied. Maybe do to lack of my
English skill.

Well what I am going to write will make it easy for
people to quickly look at it, and look at examples on
the documentation. A quick-ref source as well. I
notice ruby lacks a site like it so I will launch
documentation with my CMS(once it is finished).
Soap4r users, how do you think?


It has nothing to do about soap4r. I'm just tired
of collecting spams
to my job e-mail address (I'm an admin). Gmail
filters spams without
my computer/network resource!

Good point. Filtering all those 409 scams are painful,
and takes a great amount of resource if you have many
users. Its a pain to deal with them.

--dross




__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top