I have to call a webservice from withing a C# programm. The webservice has most probably not a standard format. The interface description (wsdl and xsd) are very complicated, and using a proxy generating mechanismus results in hundreds of classes. The generated classes ar of little help since they are very generic, having mostly simple Object types as members.The best option is to build the SOAP message manually. That is also the way the webservice provider suggested to chose: Take the soap/xml messages that has to be sent and build the message according to the template. Now the question is how to build the message most efficiently. Of course hard coding the message string is an option, however I wonder if better options exists. If I have the complete message in a string, how do I best send the messages. Should I use a simple HttpRequest or can I use mechanisms of the wcf stack? My current approach to build the message looks like this:
string msg = envelopeBegin;
RouteType rootType = new RouteType();
XmlSerializer serializer = new XmlSerializer(typeof(RouteType));
StringWriter stringWriter = new StringWriter();
serializer.Serialize(stringWriter, rootType , customNamespace);
msg += stringWriter.ToString();
msg += envelopeEnd;
// Send the message over the wire
The Soap/xml message I have to generate looks like this
<env:Envelope>xmlns:env=http://schemas.xmlsoap.org/soap/envelope/ xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://www.skanska.se/oagis/9/ws/faults">
<env:Body>
<ska:ShowSalesOrder xmlns:ska="http://www.skanska.se/oagis/9" systemEnvironmentCode="UTV" versionID="1.0" releaseID="9.0">
<!--plsql=.74s-->
<ApplicationArea xmlns="http://www.openapplications.org/oagis/9">
<!--user_name=SEBA_RAPPE-->
<ska:Sender>
<LogicalID>OEBS_SE</LogicalID>
<ComponentID>SKAIS017I</ComponentID>
<AuthorizationID>SEBA_RAPPE</AuthorizationID>
<ska:ResponsibilityID>XXOM_INTEGRATION_SVT</ska:ResponsibilityID>
</ska:Sender>
<CreationDateTime>2010-02-26T15:03:27+01:00</CreationDateTime>
<BODID>xxxxxxxxxxxxxxxxx</BODID>
</ApplicationArea>
<ska:DataArea>
<Show xmlns="http://www.openapplications.org/oagis/9">
<ResponseCriteria>
<ResponseExpression actionCode="Never" expressionLanguage="xPath">*</ResponseExpression>
</ResponseCriteria>
</Show>
<ska:SalesOrder>
<SalesOrderHeader xmlns="http://www.openapplications.org/oagis/9">
<DocumentID>
<ID>141779</ID>
</DocumentID>
<RequestedShipDateTime>2009-11-04T07:00:54+01:00</RequestedShipDateTime>
</SalesOrderHeader>
</ska:SalesOrder>
</ska:DataArea>
</ska:ShowSalesOrder>
</env:Body>
</env:Envelope>