Why chaninging tempui.org in wsdl made my service work? - c#

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?

Related

WCF SOAP namespaces

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.

Web Service XML prefix

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.

How to prepare web service and its classes based on example soap message

I got an example soap message:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/ xmlns:web="http://com.theirdomain/webservice">
<soapenv:Header/>
<soapenv:Body>
<web:Transaction>
<web:ID>123</web:ID>
<web:order>221x</web:order>
<web:trans>112-ax-21</web:trans>
<web:date>2013-01-01</web:date>
<web:title>Example title</web:title>
<web:amount>
<web:value>10.05</web:value>
<web:currency>USD</web:currency>
</web:amount>
<web:status>status</web:status>
<web:customer>
<web:address>Berlin</web:address>
<web:account>12345678901234567890123456</web:account>
</web:cusweb:customeromerData>
<web:docHash>HASHMD5</web:docHash>
</web:Transaction>
</soapenv:Body>
</soapenv:Envelope>
I need a tool or a way to quickly create a classic ASP.NET XML WebService with method NewTransaction which accepts a Transaction object. I would like to know if there is a way to quickly create class (or classes) that reflect the given soap. In the result my webservice address will be given to the other company from which they will generate WSDL and they want to call NewTransaction method with Transaction object defined in WSDL.
You can generate a WSDL and then generate a service and datacontracts from that WSDL.
It seems to be easier to just type the few properties and the single method you have in there in a new WCF Service project and fire it up. It's SOAP 1.1 so use basicHttpBinding.

sending SOAP request in asp.net mvc3

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.

Soap web service and android client using ksoap protocal mismatch

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.

Categories

Resources