I'm running into a problem getting my WCF service to work with other clients.
The ServiceContract looks like this:
[ServiceContract]
public interface IMyService
{
[OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare,
ResponseFormat = WebMessageFormat.Xml, RequestFormat = WebMessageFormat.Xml,
UriTemplate = "/calculation/{accountNumber}")]
string RunCalculations(string returnInformation, string accountNumber);
}
I wrote a simple client to make sure that everything was working, and when I pass in the xml I want, everything works swimmingly.
The problem is that the service exists to expose an interface our product to a third party vendor, who's developing a web interface in php. When he tries to issue the request, he gets a 400 Bad Request error, which, looking through the trace, is caused when WCF tries to parse his xml.
The error message I get is:
Unable to deserialize XML body with root name 'BusinessTaxReturn' and root namespace '' (for operation 'RunCalculations' and contract ('IMyService', 'http://tempuri.org/')) using DataContractSerializer.
Ensure that the type corresponding to the XML is added to the known types collection of the service.
I assume that WCF is wrapping the message that my client sends, and then attempting to unwrap it when the service recieves the message. This leaves me with two questions:
What does WCF wrap XML messages with?
What is the best way to resolve this problem? Should I just have the client wrap their message, or should I really be trying to use a DataContract?
To figure this out, use a HTTP Debugging Proxy like Fiddler to spy on the messages your WCF client sends to the WCF server, and compare these to the messages sent by the PHP app.
Related
from our application we are calling a soap service like below
res = (CreateResponse) JAXBIntrospector.getValue(getWebServiceTemplate()
.marshalSendAndReceive(soapUrl, req, new headers(msgHeader)));
now i want to see the actual request xml which is send to the SOAP url.
soapUrl - target soap url
req - it is an object of a class CreateRequest
msgHeader - it is an object MsgHeader
Because, currently we are getting an error
ns0:MsgErrorCd Description="REQUEST STRUCTURE INVALID"
So the team , which maintains the SOAP service, need the input XML,
Could you pls help me..
in the application.properties file, added the below lines, now the request xml is getting printed in the console.
logging.level.org.springframework.ws.server.MessageTracing.sent=DEBUG
logging.level.org.springframework.ws.client.MessageTracing.received=TRACE
logging.level.org.springframework.ws.server.MessageTracing.received=TRACE
I am trying to implement sample spring boot project and to ensure my endpoints are working properly, i'm using POSTMAN. When using POSTMAN , I am not able to see the response(i.e in Pretty) for a POST request. But the Status is 200 OK and I am able to see the result using GET request.
No Pretty response for POST request
GET Response ensuring that the previous POST request works fine
And my controller code is the following
#PostMapping("/message")
public Message createMessage(#RequestBody Message message)
{
return service.createMessage(message);
}
Can anyone help me to find out why I am not able to see the result while using POST method please?
Like Rafael says it is good to return a Response with the object entity. I haven't been working with Spring myself but with JavaEE and in JavaEE it is perfectly possible to return the object directly without using a Response. I use Responses anyways though, because it is much nicer to work with, and you can create your own custom responses and status codes.
Maybe check if your createUser service actually returns a message.
I don't know much about Spring, but usually what works for me is using a ResponseEntity as the object returned by the function. Also, maybe you should use #RestController as the annotation to your class controller
#PostMapping("/message")
public ResponseEntity<Message> createMessage(#RequestBody Message message)
{
Message msg = service.createMessage(message);
return ResponseEntity.ok(msg);
}
I'm very new to webservices. I'm trying to figure out how I can formulate a request message (and determine what the response message) would be based on the wsdl description that I have.
This is from a third party web service. The WSDL description that I have access to gives me a bunch of information like <types> <message> <operation> etc.
But in the examples that I've seen online, it's showing the request mesage within the "soap:envelope" tag.
What am I missing?
Eventually I'd like to be able to call this webservice using JQuery. But I can't even figure out how to formulate the request message let alone make an ajax call to it.
any help would be appreciated.
For these types of situations I would download soapUI, point it to your WSDL and use it to generate a few sample requests to get familiar with the endpoints, messages and the data model (XSD) for the service.
Armed with soapUI's sample requests it should be fairly easy to move this to jQuery's SOAP client (assuming of cause that the service is not humongous and requires you to transfer a big object graph as XML - in these cases you might want to check if your service vendor has a REST API as these are generally very easy to work with from jQuery).
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'.
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.
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...
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
I'm fairly new to WCF but am technically competent.
I am having trouble getting WCF to play nicely. I currently have a WSHttpBinding set up to a service and it is working when using the WCFTestClient supplied with VS2008. What I would like to do is have the service accessible within the browser.
I currently return a JSON response from my service but am unable, as of yet, to access the data via. a URL. I have seen lots of internet tutorials where they seem to be accessing data a bit like this (note the bolded section):
http://localhost/Service.svc/MethodName?param1=value1¶m2=value2
If I try and do that I get a 404 - I am guessing it is looking for a literal file but don't know how to fix it.
Any help you can give would be great, thanks!
You can't do that with WSHttpBinding... you need to expose an endpoint using the WebHttpBinding and have your contract correctly specify the right uri template in the [WebGet] attribute. Here are some pointers to get you started:
Rest in WCF
WebHttpBinding example
WebHttpBinding and JSON