I need to host a SOAP service for an external client who requires a specific WSDL and therefore specific input and output soap payloads. I've managed to get the payloads close but I'm having issues generating namespaces exactly how I want them on both the input payload and the output payload.
For example:
REQUIRED inbound payload:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glen="http://www.glen.com/glen/">
<soapenv:Header/>
<soapenv:Body>
<glen:ProcessXMLMessage>
<MessageID></MessageID>
<XML></XML>
</glen:ProcessXMLMessage>
</soapenv:Body>
</soapenv:Envelope>
ACTUAL inbound payload:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glen="http://www.glen.com/glen/">
<soapenv:Header/>
<soapenv:Body>
<glen:ProcessXMLMessage>
<glen:MessageID></glen:MessageID>
<glen:XML></glen:XML>
</glen:ProcessXMLMessage>
</soapenv:Body>
</soapenv:Envelope>
The only differences here is that the namespace is used on the attributes, and from what I can see there is no native way to do this in WCF. See another post on the topic that was never answered: WCF SOAP - Remove namespace from child nodes
I also had an issue with formatting the WSDL to force mandatory attributes however I was able to get around that using this: http://thorarin.net/blog/post/2010/08/08/Controlling-WSDL-minOccurs-with-WCF.aspx
Any help greatly appreciated.
Related
I have some existing code which uses a third party SOAP client to retrieve data from another third party web service. As we switched to a new data provider, we also switched to their new endpoint. We found out that our current requests are all failing and the error we get in return is "Policy Falsified".
I have used SOAP UI to test the new web service and I can successfully obtain data this way. That is why I compared the two soap messages and found out that the problem is likely with the URI used for the soap namespace.
Code generated soap message
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Request>
//...
</Request>
</s:Body>
</s:Envelope>
Working message with SOAP UI
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Request>
//...
</Request>
</soap:Body>
</soap:Envelope>
The only differences in these messages are the namespace prefixes and the soap namespace (the data inside the request tag are identical). I would like to know if this web service is rejecting my soap message purely by the soap namespace that it's using, or that something else might play a problem?
Obviously I am likely going to need to make my own implementation to generate the soap messages myself, but I'd still like to know if the webservice is set to only accept messages with that specific soap namespace or that it's some other kind of issue?
I have a soap web service which is working ok on the local server but not accessible from the outside and fails with the error that HTTP header not found.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="http://tempui.org">
but when I use
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="https:www.mycompanydomainname.org/">
It works.
The only different is that I put instead of xmlns:urn="http://tempui.org"> this, I put this xmlns:urn="https:www.mycompanydomainname.org/"
And it started working.
Why?
Our partner says he is going to send data using the SOAP protocol without using any service name to post data, like HelloWorld(string p1), just a POST.
So I am wondering how is it possible to do with SOAP?
I mean in WCF / web services, we need the name of method anyway, right?
Any clues? Thank you!
UPDATE #1
Using Wireshark I am getting this message
POST HTTP/1.1
Content-Type: text/xml
User-Agent: SOAP Sender v1.2
Host: 191.126.125.5:1212
Authorization: Basic QFNLVXNlcjE4MTghOiBAU0tQYTE5MTkh
Content-Length: 708
<?xml version="1.0" encoding="windows-1251"?>
<soapenv:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope">
<soapenv:Header/>
<soapenv:Body>
<ws:PutCoord>
<ObjectID>SG255108374</ObjectID>
</ws:PutCoord>
</soapenv:Body>
</soapenv:Envelope>
So what sort of .NET application I have to create to get this POSTED data?
This correspond to https://www.w3.org/TR/soap12-part0/#L26866
I was misled by my client HelpDesk. :)
They send data in SOAP format using HTTP to some port and thats it.
So... Sometimes HelpDesk is gonna confuse you. Hahahaha! Be careful!
Let me start this by saying I know prefix should not matter for xml that follows standards. I am forced to use a web service that requires the request to look like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:prefix="http://www.url.com">
<soapenv:Header/>
<soapenv:Body>
<prefix:Search>
<SearchCriteria>
<registrationStatus>A</registrationStatus>
<startDate/>
<endDate/>
</SearchCriteria>
</prefix:Search>
</soapenv:Body>
</soapenv:Envelope>
When I generate my request it ends up looking like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://www.url.com">
<soapenv:Header/>
<soapenv:Body>
<Search (also tried here xmlns="http://www.url.com")>
<SearchCriteria>
<registrationStatus>A</registrationStatus>
<startDate/>
<endDate/>
</SearchCriteria>
</Search>
</soapenv:Body>
</soapenv:Envelope>
Because the prefix is missing I get an error saying it can't find the search child. Using fiddler I have recomposed this message a million different ways and all fails unless I add the prefix and the namespace for it. I don't own the web service and the owner won't make changes so I am stuck trying to figure it out.
My question is how can I add the prefix and the namespace to the request? I have added the service to my c# console test app using add service reference, I tried modifying the qualified and not qualified settings but that did not add the prefix.
I was able to find a good solution here Intercept SOAP messages from and to a web service at the client
This worked perfectly for anyone else looking to do the same
i think you have to provide targetnamepace for your class Search.
I want to send following SOAP/XML request and get the SOAP response back in asp.net mvc/C#
<?xml
<soapenv:Envelope
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:myurn">
<soapenv:Header/>
<soapenv:Body>
<urn:fLocHistory
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<HistRequest
xsi:type="urn:SubMemLocationHistoryRequest">
<MSID xsi:type="xsd:string">test</MSID>
<AID xsi:type="xsd:int">2</AID>
<MemMSISDN xsi:type="xsd:string">test</MemMSISDN>
</HistRequest>
</urn:fLocHistory>
</soapenv:Body>
</soapenv:Envelope>
What is the better way to send request. I have seen example regarding MSXML2, WCF or asmx. If you could point some good starting tutorial. I have seen some examples here and here and here.