user385693
user385693

Reputation: 53

How do I create a Ruby SOAP client without using a WSDL?

I need to write a soap client that is capable of sending and receiving soap messages.

This soap service does not have an associated WSDL file and soap4r and savon both seem to require one.

I have an example of what I need to do in Java, see the link below.

http://community.cecid.hku.hk/index.php/product/article/writing_hermes_2_ws_client_under_java/#ebms-2_0-sender-ws

I could use java for this, at this point it seems like it would be easier. However I personally prefer coding in ruby and our company has more ruby resources than java.

Can anyone confirm thats its possible to do something similar to java example in ruby without writing my own specialised soap library?. I need to be able to send a payload, which I believe is usually in the form of a soap attachment.

I am particularly interested in seeing soap4r examples that don't use a WSDL as I have had trouble finding any with google.

Any help much appreciated.

Upvotes: 5

Views: 3554

Answers (3)

bimbom22
bimbom22

Reputation: 4510

as of Savon v2, the syntax is slightly different

client = Savon.client do
  endpoint "http://example.com"
  namespace "http://v1.example.com"
end

http://savonrb.com/version2/client.html

Upvotes: 5

rubiii
rubiii

Reputation: 6983

Savon does not require a WSDL document. Please take a look at the new documentation. If you know the SOAP endpoint and target namespace, you can execute a SOAP request like this:

client = Savon::Client.new
  wsdl.endpoint = "http://example.com"
  wsdl.namespace = "http://soap.example.com"
end

client.request :any_soap_action do
  soap.body = { :do => "something" }
end

Upvotes: 1

Zeno Davatz
Zeno Davatz

Reputation: 1

client = Savon::Client.new
  wsdl.endpoint = "http://example.com"
  wsdl.namspace = "http://soap.example.com"
end

This does not work, it misses a the block name and the "e" in namespace:

client = Savon::Client.new do | wsdl |
  wsdl.endpoint = "http://example.com"
  wsdl.namespace = "http://soap.example.com"
end

Upvotes: 0

Related Questions