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.
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!
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.
I have and android client, that uses ksoap to communicate with a wsdl web service written in c# asp.net. I have a problem with matching the argument types between the web service and the client.
The web server expects to this kind of request (auto generated):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetDetails xmlns="http://host.org/">
<event_id>int</event_id>
</GetDetails>
</soap:Body>
</soap:Envelope>
the client sends requests using ksoap, and they look like this:
<v:Envelope xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:c="http://schemas.xmlsoap.org/soap/encoding/" xmlns:v="http://schemas.xmlsoap.org/soap/envelope/">
<v:Header />
<v:Body>
<n0:GetDetails id="o0" c:root="1" xmlns:n0="http://tempuri.org">
<event_id i:type="d:int">1</event_id>
</n0:GetDetails>
</v:Body>
</v:Envelope>
For some reason the WS parses the following' client's request as 0 (I guess because of the additional type attributes - i:type="d:int") when the request is assembled manually to look like the first option, it works correctly.
How can i make the web service read the ksoap format correctly or how can i change it's expected format to look like ksoap request. (the web service soap protocol is auto generated).
Well the solution has 2 parts:
1. regarding removing the attribute types, I found the answer here:
using addMapping without the "i:type=" attribute in ksoap2 for android
I neede to set:
envelope.implicitTypes = true;
The name space has to end with a backspace, and i missed it.