I'm working on an integration project and need to do a webservice (it has to be in .asmx) to process the XML of this request:
POST /dSoapServiceSoapBindingService.asmx HTTP/1.1
Host: www.meusite.com
User-Agent: gSOAP/2.8
Content-Type: application/soap+xml; charset=utf-8; action="tns:CrossEvent"
Content-Length: 685
Connection: close
SOAPAction: "tns:CrossEvent"
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://digicon.com/dFlow/common/v1/" xmlns:ns1="http://digicon.com/dFlow/gate/v1/" xmlns:ns3="http://digicon.com/dFlow/dSoap/v1/">
<SOAP-ENV:Body>
<ns3:CrossEventRequest>
<GateID>teste</GateID>
<Travellers>
<ns2:TravellerCross>
<ns2:TravellerID>123456</ns2:TravellerID>
<ns2:Cross>CANCEL_CROSS_ENTRANCE</ns2:Cross>
</ns2:TravellerCross>
</Travellers>
</ns3:CrossEventRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I made the webservice receive the request (I can put a breakpoint in the method and it fires) but I can not recover the parameters GateID
and Travellers
. They are getting null. I know the problem is with the namespaces and prefixes used (since when I make the Hello World example using the default namespaces it works) but I can not hit my webservice with these XML namespaces.
My webservice looks like this:
[WebService(Namespace = "http://digicon.com/dFlow/dSoap/v1/")]
[System.Xml.Serialization.XmlSchemaProvider("http://www.w3.org/2001/XMLSchema")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class dflow : System.Web.Services.WebService
{
[XmlNamespaceDeclarations]
public XmlSerializerNamespaces xmlns
{
get
{
XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
xsn.Add("ns2", "http://digicon.com/dFlow/common/v1/");
xsn.Add("ns1", "http://digicon.com/dFlow/gate/v1/");
xsn.Add("ns3", "http://digicon.com/dFlow/dSoap/v1/");
return xsn;
}
}
[WebMethod]
[SoapDocumentMethod(Action = "tns:CrossEvent", ResponseElementName = "CrossEventResponse", RequestElementName = "CrossEventRequest")]
public string CrossEventRequest(string GateID, List<TravellerCross> Travellers)
{
// CÓDIGO DO WEBSERVICE
return "Processado";
}
}
The TravellerCross class looks like this:
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://digicon.com/dFlow/common/v1/")]
public class TravellerCross
{
[XmlElement(Namespace = "http://digicon.com/dFlow/common/v1/")]
public string TravellerID { get; set; }
[XmlElement(Namespace = "http://digicon.com/dFlow/common/v1/")]
public CrossEnumType Cross { get; set; }
[XmlNamespaceDeclarations]
public XmlSerializerNamespaces xmlns = new XmlSerializerNamespaces();
public TravellerCross()
{
xmlns.Add("ns2", "http://digicon.com/dFlow/common/v1/");
}
}
public enum CrossEnumType
{
CROSS_VALID_ENTRANCE = 1,
CROSS_VALID_EXIT = 2,
CROSS_INVALID_ENTRANCE = 3,
CROSS_INVALID_EXIT = 4,
CANCEL_CROSS_ENTRANCE = 5,
CANCEL_CROSS_EXIT = 6
}
Can anyone explain to me what is missing or wrong? I do not know where else to look. I can not find consistent documentation to help me. Thanks in advance for all your help.