add_method_with_soapaction - for nested data

17 views
Skip to first unread message

ben

unread,
Sep 14, 2006, 3:42:01 PM9/14/06
to soap4r
I've got simple SOAP calls working but I can't seem to figure out how
to do a soap call for complex/nested sets.

Using this type of code:
service =

SOAP::RPC::Driver.new("http://www.ioperate.net/ws/order/orderws.asmx","http://chrome52/webservices/")
service.default_encodingstyle =
SOAP::EncodingStyle::ASPDotNetHandler::Namespace
service.wiredump_dev = STDERR
service.add_method_with_soapaction(
"OrderUpload",
"http://chrome52/webservices/OrderUpload",
"VendorCode",
"VendorAccessKey",
"Batch"
)
service.wiredump_dev = STDERR
service.OrderUpload(VENDOR_CODE, VENDOR_ACCESS_KEY,nil)

How would you do the add_method_with_soapaction calls for data that
needs to be in this format:
http://www.ioperate.net/ws/order/orderws.asmx

Also - I've got this in file form (using rxml to generate it) ... isn't
there just some simple method of posting a soap xml file to a server?

ben

unread,
Sep 16, 2006, 10:43:27 AM9/16/06
to soap4r
Thanks for all the replies :)

Here's how you do this.. god forbid this be documented anywhere - guess
that's the Ruby way...

For the search engines - this is the simplest way to post complex xml
formats to .net dotNet webservices using ruby

xml = (some xml string some like what's shown here
http://www.ioperate.net/ws/order/orderws.asmx?op=OrderUpload )
require 'net/http'
h = Net::HTTP.new('www.ioperate.net', 80)
#you just pretty much copy the header info seen on
http://www.ioperate.net/ws/order/orderws.asmx?op=OrderUpload )
headers = {
"Host" => "www.ioperate.net",
"Content-Type" => "text/xml; charset=utf-8",
"Content-Length" => xml.size.to_s,
"SOAPAction" => "http://chrome52/webservices/OrderUpload"
}
resp, data = h.post('/ws/order/orderws.asmx', xml, headers )
render :text => data

tpo

unread,
Sep 18, 2006, 3:39:50 AM9/18/06
to soap4r

ben wrote:
> Here's how you do this.. god forbid this be documented anywhere - guess
> that's the Ruby way...

You could document it here:

http://rubymanual.org/class/Net%3A%3AHTTP#post

Actually I was going to do it for you, but I wasn't sure to what you
where referring when you said 'that' wasn't documented anywhere.

I see that aparently there's no documentation there, on how to set the
headers, however, I haven't ever used the HTTP class, so I haven't read
all the docu there is about it.

Is there anything else, that you're missing in the docu? You could of
course add the whole example as is as a comment?

ben wiseley

unread,
Sep 18, 2006, 11:57:03 AM9/18/06
to soa...@googlegroups.com, tomas.p...@sbb.ch
Tomas,

Thanks for the email.  I was just frustrated - it seems like 1/2 of ruby (and rails) is really badly documented or they have ridiculously simple examples that obviously don't cover anything in the real world and include 5% of what you can actually do (Rails is notoriously bad about this IMO).   You know - tons of function-takes-"mysterious"-hash with a "here's one item you could put in the hash... have fun guessing the rest..." :)

While using webrick the wsdl version of this worked the first time but then failed until I restarted webrick.  I'm assuming that's how you'd do this with soap4r but it seemed buggy when mixed with rails.  So I reverted to just doing posts - which got it working.

As for using this as documentation - I don't know - it's kind of a hack/work-around.  Seems like it'd be better to include some documentation on how this would be done with soap4r (specifically - how you build complex/nested data elements).  I.E. how do you do this method to create a more complicated data element with soap4r?

   require "soap/rpc/driver"
    service =
    SOAP::RPC::Driver.new(" http://www.ioperate.net/ws/inventory/inventoryws.asmx","http://chrome52/webservices/")

    service.default_encodingstyle =
    SOAP::EncodingStyle::ASPDotNetHandler::Namespace
    service.add_method_with_soapaction("InventoryCountQuery",
    "http://chrome52/webservices/InventoryCountQuery",
    "VendorCode","VendorAccessKey","Sku")
    service.wiredump_dev = STDERR
    service.InventoryCountQuery(VENDOR_CODE, VENDOR_ACCESS_KEY,sku)
So - if VendorCode in the example above is a nested element (like <VendorCode><id/><name/><whatever/><?VendorCode> ) ... how do you that kind of thing?

And I'm working 16+ hours a day, stressed out and have no time to do anything more than keep my head above the water (which I'm assuming is pretty common with most coders).  :)

NAKAMURA, Hiroshi

unread,
Sep 24, 2006, 9:23:54 AM9/24/06
to soa...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Sorry for late reply.

ben wrote:
> I've got simple SOAP calls working but I can't seem to figure out how
> to do a soap call for complex/nested sets.
>
> Using this type of code:
> service =
>
> SOAP::RPC::Driver.new("http://www.ioperate.net/ws/order/orderws.asmx","http://chrome52/webservices/")
> service.default_encodingstyle =
> SOAP::EncodingStyle::ASPDotNetHandler::Namespace
> service.wiredump_dev = STDERR
> service.add_method_with_soapaction(
> "OrderUpload",
> "http://chrome52/webservices/OrderUpload",
> "VendorCode",
> "VendorAccessKey",
> "Batch"
> )
> service.wiredump_dev = STDERR
> service.OrderUpload(VENDOR_CODE, VENDOR_ACCESS_KEY,nil)
>
> How would you do the add_method_with_soapaction calls for data that
> needs to be in this format:
> http://www.ioperate.net/ws/order/orderws.asmx

Try to create client stub with wsdl2ruby.rb. You can get wsdl2ruby.rb
(if you don't have it) from
http://dev.ctor.org/soap4r/browser/trunk/bin/wsdl2ruby.rb?format=txt

Run wsdl2ruby.rb against http://www.ioperate.net/ws/order/orderws.asmx?WSDL

% wsdl2ruby.rb --wsdl
"http://www.ioperate.net/ws/order/orderws.asmx?WSDL" --type client --force

You'll get default.rb, defaultDriver.rb and OrderWsClient.rb. See
OrderWsClient.rb how to call the method.

Regards,
// NaHi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)

iQEVAwUBRRaG6R9L2jg5EEGlAQKbhgf/T91OGvqJ+iRuGKDxHGcFOxZgGzNnZ1ka
tDh5wCsm0TwP/Ybs8lp+fRv0qQQtoIGljAVA1B7kq3HTHQP7XzChYIyufTxHcDbC
2FWvjtJaSr+hdMwWAkRU8tO5D6bdRS3juNl+bZbYModQVWE9KqMnT0BYxGdR3RBo
/1KsdFcpfdZ6ZFnc8cp5DiqJvhejA8d6MtETp5CfKm9mU69Aqlxv9nLSwhYkyFrT
Wan0vyCFzRcmiD8Vvy0hWZtkDViXuKc10pE6ecDxC6tsuZQA94MWZl3fq/z5Xp8H
vm5iRuqNeTII1kGCUJkCJN/LwrAGJlMEV7e8ueoHSrBTSsWgUW7TeQ==
=ni5w
-----END PGP SIGNATURE-----

Reply all
Reply to author
Forward
0 new messages