1
Reply

Web Service call dynamically using HTTPWebRequest

Rajeev Ranjan

Rajeev Ranjan

Mar 5 2012 10:49 AM
4k
Hi,

I am writting one application that will call any SOAP Web Service dynamically. I used HTTPWebRequest object of C# for this but I receive different format of Request and Response packet. I am not able to identify how to create such request packet (XML) so it will work for all type of Web Services. Example one service takes all input parameter under METHOD NAME tag in SOAP:body. Another service takes one more tag between input parameter and METHOD NAME tag. Same happens with Response packet. Even namespace is also different in request packet. Please check below 2 examples. I am not sure how to handle such scenario.

Can anybody tell me how to handle such thing.

Thanks in advance.

<?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>
    <ConversionRate xmlns="http://www.webserviceX.NET/">
      <FromCurrency></FromCurrency>
      <ToCurrency></ToCurrency>
    </ConversionRate>
  </soap:Body>
</soap:Envelope>
=====================================================================
<?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:Header>
    <UserCredentials xmlns="http://www.xyz.com/Services">
      <userid>string</userid>
      <password>string</password>
    </UserCredentials>
  </soap:Header>
  <soap:Body>
    <ChangeAccountInfo xmlns="http://www.corecard.com/Services">
      <ChAcctRequest>
        <AccountNumber>string</AccountNumber>
        <CardNumber>string</CardNumber>
        </ChAcctRequest>
    </ChangeAccountInfo>
  </soap:Body>
</soap:Envelope>

Regards,
Rajeev

Answers (1)