How to call a WCF SOAP web service using Postman - wcf

I'm following these instructions from the Postman blog to call a WCF (SOAP) web service using Postman:
Postman makes SOAP requests too
I keep getting this error message back:
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).
There is no security on this particular service prototype and when I examine the WCF service logs I see this message in red:
Process action''.
Any idea how to get around this problem and map a SOAP Action in the request?

I found a workaround by specifying a request header with a SOAPAction key and value of: http://tempuri.org/I<My Service Name>/<Method Name>
Hope this helps!

If you have called your service in SaopUI client, then you can get the correct SOAPAction header value there under the Raw tab in the request window in SoapUI.

Related

Read SOAP message header WCF

I have a WCF service with ws-security using wsHttpBinding. In one of my method, I want to read the ws-security SOAP header. How do I do it?
I have visited this link but not getting idea. I simply want to read the soap header in one of the operation contract in my WCF service.
Is it possible to receive a soap message in a WCF method?
Thanks,
Jay
Jay,
Yes is possible to receive a SOAP message in a WCF method, but what I think you want is to read the header variables in the inbound request.
On the host side, create an object from this:
System.ServiceModel.OperationContext.Current.IncomingMessageHeaders
This will return an indexed collection of the inbound message headers sent from the client, and you can read it this way:
OpContext.IncomingMessageHeaders(0).ToString

WCF: Catching Response that is not SOAP

I am have been setting up a WCF Client to connect to a Service that I do not have control of (I think the service is implemented in Java).
The service requires Certificate security and I got all the certificates setup but I get the following error when I connect to the endpoint
An HTTP Content-Type header is required for SOAP messaging and none was found.
I have setup SchemaValidationMessageInspector (http://msdn.microsoft.com/en-us/library/aa717047.aspx) to catch the Request and Response.
I can see that the Request is caught but not the response.
As I understand it is because the response is not of the SOAP format meaning that the Validation method is not triggered.
I expect that the real error is a 404, 403, 500 or something like that.
I have been using Wireshark to inspect the packets but it's all encrypted since it's too early in the "stack". I need the response right after the https decryption have occurred.
How can I catch the none SOAP responses so I can see the error in a clear format?
Use Fiddler or WCF Trace http://blogs.msdn.com/b/madhuponduru/archive/2006/05/18/601458.aspx to see the raw message. If you want to do this from code use a WCF custom messgae encoder http://msdn.microsoft.com/en-us/library/ms751486.aspx.

Where is SoapAction configured in WCF Client?

I need my wcf client to communicate with the service with a blank SoapAction because the service is configured to dispatch the operation by body of the soap message. And the operation contract is decorated as below so it will not require soap action. I guess WCF sends a soapaction by default. Is there any option in wcf client to send a blank soapaction? Thanks for any help!
[OperationContract(Action="")]
use the same OperationContract attribute on your client code, i.e. reference.cs. More details here.

How do I get the correct schemaLocation into my WCF service's WSDL?

I have written a simple WCF web service that I am trying to expose through a website.
I uploaded the website (which has the service reference and bindings in the web.config) to the server and I can browse to the wsdl using https://domain/ServiceRoute?wsdl.
The WSDL is showing an incorrect path for schemaLocation.
I then try to use the WCF Test Client to test the service. The WCF Test Client gives me the following error:
Error: Cannot obtain Metadata from https://domain/ServiceRoute?wsdl If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: https://domain/ServiceRoute?wsdl Metadata contains a reference that cannot be resolved: 'https://domain/ServiceRoute?wsdl'. Sendera:ActionNotSupportedThe message with Action 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get' 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).HTTP GET Error URI: https://domain/ServiceRoute?wsdl The document was understood, but it could not be processed. - The WSDL document contains links that could not be resolved. - There was an error downloading 'https://incorrectSchemaLocation/ServiceRoute?xsd=xsd0'. - The remote name could not be resolved: 'IncorrectSchemaLocation'
I'm not sure what to do about this. Is there a server setting I need to change? Or can I update my bindings to explicitly use the schemaLocation of https://domain/ServiceRoute?
Also, note that I am not getting ssl certificate errors when I browse to the wsdl. I don't know if that helps.
I was able to get around this error by changing the web server's configuration using a command line utility:
cscript.exe adsutil.vbs set /w3svc/<site identifier>/SecureBindings ":443:<host header>"
Where <site identifier> is the IIS site identifier and <host header> is the URL that will be used to access the service from the outside (ie: subdomain.domain.com.)

How to get the soap or http request object from a wcf class

From a wcf4 service need to access to the underlying http request,including it's soap message, how can I do that from code?, I know I can use fiddler, etc, but need to do it programatically.
Look at Message Inspectors.