This is the situation, there is an existing client, I need to build a server the client will be consuming. I don't own the client and am in no position to change it. The client soap message can be follows
How do I make my service accept both of the circled prefixes. Currently it only accepts "c2b" prefix and its not processing any requests with "ns1" prefix.
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
Because a and b and c , so it's name is C. C came out of Ken Thompson's Unix project at AT&T. He originally wrote Unix in assembly language. He wrote a language in assembly called B that ran on Unix, and was a subset of an existing language called BCPL.
You are passing the DTO(Class object) to service but your wcf service is not able to recognize the exact class.
So to make WCF accept any prefixes just add that prefix with proper object location.
You Need to just add one more xmlns
attribute to <soapenv:Envelope>
.
Eg.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://cps.huawei.com/cpsinterface/c2bpayment" xmlns:c2B="http://cps.huawei.com/cpsinterface/c2bpayment">
Honestly, you might be up a creek here. You have a client that is providing a completely invalid SOAP message -- it is using a namespace prefix that it isn't declaring at all.
I don't have time to try it out, but my first thought was maybe using XmlNamespaceDeclarationsAttribute might work -- you could provide it on your root C2BPaymentConfirmationRequest class, and pre-fill it in your constructor with "ns1" pointing at "http://cps.huawei.com/cpsinterface/c2bpayment". Worth a try. Let us know if it works out.
Shubham Sharma's answer is 100% correct.
To add a little bit more explanation, these prefixes are just alias of the namespaces you declared. They don't mean anything. If you want to use ns1 as the prefix, all you need to do is to replace xmlns:c2b with xmlns:ns1 at the top.
In your case, the client doesn't know how to generate the request. Maybe it is better to advise them to use some request generation tool based on the wsdl - such as SoapUI.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With