Call web service without proxy

I need to call webservice using a C # program. Webservice has, most likely, not a standard format. The description of the interface (wsdl and xsd) is very complicated, and using the proxy generation mechanism leads to hundreds of classes. The generated ar classes are of little help, since they are very general, having mostly simple object types as members. The best option is to create a SOAP message manually. This is also the way the web service provider suggested: accept the soap / xml messages to send and create a message according to the template. Now the question is how to create a message most effectively. Of course, hard-coding a message string is an option, but I wonder if there are better options. If I have a complete message in a line, what is the best way to send messages.Should I use a simple HttpRequest or can I use the wcf stack mechanisms? My current approach to creating a message is as follows:

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 a message by cable

The Soap / xml message I need to create 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> 
+3
source share
2 answers

You can definitely use the WCF framework without requiring a type definition for all of the various messages. WCF specifically supports this through the Message class . Using it is not that difficult. Here is more detailed information about them, but the idea is that you will use XML readers and writers to read and write messages.

Using the message class

+2
source

- XML, . XML , . XML -, HttpWebRequest.

, - WCF , - , . WSDL, WCF . , - -, , , - -. -, , .

0

Source: https://habr.com/ru/post/1734710/


All Articles