3

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'.

Case
  • 1,848
  • 21
  • 32

3 Answers3

3

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.

Case
  • 1,848
  • 21
  • 32
  • I confess I don't know Ruby, but I have had problems with WCF and Java because the WSDL contains references to external .xsd files. You can generate a single WSDL using the svcutil.exe tool. You may also find these WCF tools useful: http://wcfextras.codeplex.com/ – Aidan Black Mar 06 '14 at 16:41
  • I have seen this post so many times. So I have been trying for days to talk with a SOAP WCF service with soap. I just got it to work. The key take away is the version of Savon you're using. Savon 2.0 - I would setup the wsdl to a varable of client. Then when calling client.operations result# => [] Savon 3.0 (unstable) you build the client Operations then then calls the Operation. Operation = {service_name, port_name, operations_name} Setup the Operations.body and call it. see http://savonrb.com/version3/getting-started.html for more help. 3.0 worked for basicHTTPBinding – JamesDeHart Aug 18 '15 at 23:12
1

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
ktambascio
  • 434
  • 4
  • 17
1

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...

Michael Baldry
  • 1,990
  • 2
  • 14
  • 28
  • 1
    Did Savon not work for you? What were the issues that Savon had? – Steve Weet Aug 22 '10 at 13:31
  • @Steve Weet: I attempted to use it, it kept throwing exceptions in the Savon code. Can't remember exactly the problem, but couldn't work out what I was doing wrong from the docs, or a search online so I gave up. Btw - I live in Rainham – Michael Baldry Aug 22 '10 at 18:27
  • 1
    I've had some success with Savon but SOAP with Ruby is not a happy experience. Ever since ActionWebService was dropped from Rails Core no-one seems interested in SOAP. It's a shame if you live in a corporate world where you have to support SOAP. Nice to know I'm not the only Rubyist in Medway. – Steve Weet Aug 22 '10 at 20:39
  • Thanks so much for the responses. That is what I was beginning to gather from my attempted use of Ruby's SOAP libraries also. On the other hand, the generated drivers from soap4r seemed to have proper object support, so I thought I must just be missing something. If it's not too much effort, seeing the code you used to hand-generate the requests would be quite helpful. @Steve Weet Have you worked with Savon at all with WCF services? If so, is there any documentation on it that you found helpful? Thanks again. – Case Aug 23 '10 at 05:58