Successfully calling a WCF Service from Ruby? Anyone?

3.8k Views Asked by At

I'm trying to integrate a rails application with a WCF service. I've tried soap4r and Savon with no love at all. As far as I can tell, none of the Ruby libraries support the newest version of SOAP.

The error that I was getting was:

Cannot process the message because the content type 'text/xml;charset=UTF-8' was not the expected type 'application/soap+xml; charset=utf-8'.'application/soap+xml; charset=utf-8'.

I managed to beat this error by changing the WCF service binding from wsHttpBinding to basicHttpBinding, but then received the new error:

The message with Action '' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None). (SOAP::FaultError)

Now, this error leaves me baffled because I don't see any way to configure endpoints in any of the Ruby libraries. Does anyone know?

Has anyone successfully called WCF services from Ruby?'application/soap+xml; charset=utf-8'.

3

There are 3 best solutions below

2
On BEST ANSWER

Please note that I got this working...after I changed the web.config for the service to basicHttpBinding, Savon is able to send and receive messages. It is only soap4r that is unable to still and throws the Action '' error.

4
On

this may not be what you want t hear but I've recently been interacting with SOAP in Ruby.... It's not fun at all, none of the gems available are complete, stable or well documented and all seem to fall down when you add a tiny bit of complexity (passing an object containing some values instead of just passing a integer or string).

I ended up sniffing the request made by a .net client, then building objects that have a .to_xml method, taking a XML Builder object and adding it's own stuff..

That takes care of the request and then each service request method is custom made to extract the information needed for the result.

Very manual way to do it, and have to add more for every method i need to use but at least it works!

Some other guys I work with had success using JRuby and Axis. I stayed away from this as I wanted a pure Ruby solution.

Sorry I couldn't be of more help.. if you'd like I'll post my code to build the soap request...

0
On

I was running into the same issue with Savon with my WCF web service. The content error is because your service is expecting SOAP 1.2, but by default Savon sends the request as SOAP 1.1.

The Content-Type value for 1.1 is 'text/xml;charset=UTF-8', but if the server is configured for 1.2 (which is what wsHttpBinding is), the Content-Type must be 'application/soap+xml; charset=utf-8'.

I found this method on the Savon website:

response = client.request :get_user do
  soap.version = 2
end