Changing the Prefix in WCF Response - wcf

While calling from my Web Application, WCF response i am getting is :
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<getSOAPDataResponse xmlns="http://localhost/WebServices">
<getSOAPDataResult> INFORMATION </getSOAPDataResult>
</getSOAPDataResponse>
</s:Body>
</s:Envelope>
The Web Application is very old and has some hard coded stuff that looks for "Soap" as prefix in Response.
Previously Web Services were used but now Web Services has been migrated to WCF Services.
The expected response from WCF is something like this:
<Soap:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<Soap:Header />
<Soap:Body>
<getSOAPDataResponse xmlns="http://localhost/WebServices">
<getSOAPDataResult> INFORMATION </getSOAPDataResult>
</getSOAPDataResponse>
</Soap:Body>
</Soap:Envelope>
So i need to change the WCF Response Prefix "S" to "Soap". How can it be done. Any help will be highly appreciated.
Thanks in advance.

This blog post addresses your exact problem. You basically need to create a custom message encoder. Be aware though, if you're using WsHttpBinding with message security, the approach in the post won't work. If you're using BasicHttpBinding, refer to the comments at the end of the post (you need to ensure you're replacing the right text, as the basic binding uses SOAP 1.1 and the WS binding uses SOAP 1.2).

Related

send array of int in wcf soap postman

Let's say I have a function that contains List ids argument in WCF SOAP, how can I post an array of ints to that WCF SOAP vis Postman? I swear I've looked everywhere in Google, but there is no documentation about it. Help!!
You want to use postman to test your service, but postman only supports http requests. If you want to send a soap request, you need to edit it in the body, and the sending format needs to be soap-xml. For soap requests, you can use soapUI to test your SOAP service. In short, if your service uses soap binding, you can use soapUI to test your service to send parameters, if you use webhttpbinding, you can use postman to send parameters and call the service.
#Theobald Du: This is what I'm trying to do. I know it is soap-xml, yet i don't know how to send an array of ints through. Here is what I have so far:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetAvailabilities xmlns="http://tempuri.org/">
<bodyString>leg</bodyString>
<clinics>
--> (list of ints to send here. This is where I am stuck)
</clinics>
</GetAvailabilities>
</s:Body>
</s:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<GetAvailabilities xmlns="http://tempuri.org/">
<bodyString>leg</bodyString>
<clinicsxmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:int>594</a:int>
</clinics>
</GetBranchAvailabilities>
</s:Body>
</s:Envelope>
This is the correct way to do it. Since there is no documentation about it whatsoever, i will leave it up there for anyone that needs an example

How to test WCF wsHttpBinding endpoint along with certificate using SOAP UI tool?

I want to test my wcf service endpoint using SOAP UI tool which is built in wsHttpBinding along with x509certificate authentication. It supports for basicHttpBinding and working properly but giving an error for wsHttpBinding. Any help would be appreciated. I'm getting below error message in response.
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
<a:RelatesTo>uuid:81f1ec47-0bd4-4dd0-b958-648ee934be24</a:RelatesTo>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-US">An error occurred when verifying security for the message.</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>
We are capable of testing the WCF service in SOAPUI if WCF service is created by Wshttpbinding and the required client credential is a certificate.
Please refer to the reply I wrote several days ago.
Test WCF with Mutual Certificate Authentication using SOAPUI
Merely based on the security error. I could not infer that the code design on the server-side. I would like that you could post more details of the security binding configured on the server-side and the client's credential type so that I could make an example.
Besides, here are some links, wish it is useful to you.
WCF wsHttpBinding in SoapUI
https://www.soapui.org/docs/functional-testing/sending-https-requests.html
Feel free to let me know if there is anything I can help with.

SoapUI WCF using SSL certificate

After looking around the forums and the internet in general, I was unable to find anything that answered my problem, so I have resorted to placing my question here.
Firstly, sorry if this has already had an answer supplied.
My problem is this. I have an existing C# WCF service hosting in IIS and secured by an SSL. This is working code and is currently in our Live, UAT, Test and Development environments.
I have been asked to use SoapUI for testing firstly on existing services and any new services that we are about to build.
So far, I have created the project by supplying the WDSL, setup the keystore with the SSL cert, created an outgoing and incoming WS-Sec config.
When in the request, I have created a basic authorization using the defined outgoing and incoming configs created above.
After clicking on the submit button, I get the following response.
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" ns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
<a:RelatesTo>uuid:89964641-b66d-42c7-b40a-bdd3b7acdddf</a:RelatesTo>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value xmlns:a="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:InvalidSecurity</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="en-GB">An error occurred when verifying security for the message.</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>
I did see an article that inferred that I should switch the 'Enable WS_A addressing' switch off. I did this, but this just caused the submit request to timeout.
I have checked that the service is running by viewing the WSDL from the IIS server and also using the application to call the service and all is OK.
I am sure that I missed a simple step, so would be grateful for any help.
Thanks
After looking around, I have started to use WCF Storm which does appear to work with WCF using SSL.

Web service client needs to add type attribute to password security header

I'm writing a .NET client (WCF) that will consume a web-service that is implemented using Apache CXF (Java) and amazingly enough it's incredibly hard have WCF to set the Type attribute of the Password tag to PasswordText. I.e I would like the SOAP header to look something like:
<wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-11" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">a287645857cfaaddf82e2d333651b3e0</wsse:Password>
<wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">oKGlwEkbkhYJH6upsbiqeQ==</wsse:Nonce>
<wsu:Created>2011-10-25T13:10:11.958Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
but the actual header looks like:
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:UsernameToken u:Id="uuid-5acb0b47-1b52-4535-bfaf-b9e76621b7eb-1">
<o:Username>test</o:Username>
<o:Password>a287645857cfaaddf82e2d333651b3e0</o:Password>
</o:UsernameToken>
</o:Security>
As you can see the Type attribute is missing from the Password tag. Some research on the web seems to indicate that I perhaps have to write an interceptor to fix this. I figured that there was a simple solution, i.e. config setting, to fix this but maybe there is not. Anyhow, I'm hoping for some clarifications by posting this question.
The WS server rejects the request because of the missing Type attribute. Some function checking for BSP spec. compliance (not sure what this is) throws an exception.
Regards, Ola
OK, the implementation requires using WSE 2.0 SP3. Be careful NOT WSE 3.0.
WCF cannot help you.
All you need is here.
This is a better sample.

Call WCF Using SOAP call

I want to call a WCF service using SOAP?
this is my contract:
[ServiceContract(Namespace = "http://www.MySite.com/Services/TransferFile")]
public interface ITransferFile : ICloseableAndAbortable
{
/// <summary>
/// This will send the file which is associated with this rule to all the subscribers.
/// </summary>
/// <param name="ruleId"></param>
[OperationContract]
void ByRuleId(int ruleId);
}
the binding is currently set to this, will i need to change it?
<endpoint address="" binding="wsHttpBinding" contract="FileTransfer.Wcf.ITransferFile">
so how would i call it via soap? for example using the (HttpWebRequest)WebRequest
Many thanks in advance
Change the Binding to basicHttpBinding
2 the message
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<ByRuleId xmlns="http://www.MySite.com/Services/TransferFile">
<ruleId>3</ruleId>
</ByRuleId>
</soap:Body>
</soap:Envelope>
3 the soap action
POST /FileTransferService/TransferFile.svc HTTP/1.1
SOAPAction: "http://www.MySite.com/Services/TransferFile/ITransferFile/ByRuleId"
fyi i asked for a (HttpWebRequest)WebRequest, only as a posible way, I ended up using a Web Reference and fiddler
Is there a reason you prefer WebRequest instead of generating a client proxy with svcutil.exe which takes care of all the plumbing?
There's a number of ways you can do this:
create a little WCF client for your service yourself, by using svcutil or "Add Service Reference" in a Visual Studio project
run a SOAP testing tool like SoapUI or WCFStorm against your service and create requests and call your service (and see the results)
use the WCF test client WcfTestClient.exe which is in your (Visual Studio)\Common7\IDE\Tools\bin (?? not 100% sure about the location - check and you'll find it for sure!) and which allows you to connect to a running WCF service, inspect its operations, and also call them
Marc