SOAP xml client - using Visual Studio 2010 c# - how?

10,932

If you have a WSDL/XSD to describe that service, or if you can navigate to an URL to grab that metadata, then WCF with basicHttpBinding would probably be your best bet. WSDL is definitely not "legacy" - if anything is legacy, then it's ASP.NET/ASMX webservices.

Given a WSDL/XSD or a URL where you can connect to, just do an Add Service Reference from within Visual Studio, and you should be up and running calling your WCF service in no time - trust me! You don't need to know all of WCF just to call a simple SOAP web service.... also, with WCF 4.0, lots of things - especially configuration - have been vastly improved and simplified.

As for resoures: there's the MSDN WCF Developer Center which has everything from beginner's tutorials to articles and sample code.

Also, check out the screen cast library up on MSDN for some really useful, 10-15 minute chunks of information on just about any topic related to WCF you might be interested in.

Share:
10,932
rita
Author by

rita

Updated on June 06, 2022

Comments

  • rita
    rita almost 2 years

    I'm new to .NET world, yet have to use VStudio C# 2010 (.NET 4.0) to produce a client that requests data from a web service in SOAP Xml fashion. I've searched here for answers but got confused even more. MSDN says that "Building XML Web Service Clients" is legacy for .NET 4.0, i.e. WSDL is legacy. Use "WCF" instead, they say. In WCF i got lost - too much and too vague. It must be simpler then that... And all examples that i could find on the web - they all use WSDL, "the legacy".

    Here are the definitions of the service i need to use in order to obtain the data from the web service:

    request:

    POST /catalog.asmx HTTP/1.1
    Host: www.somewebsite.com
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "https://www.somewebsite.com/KeywordSearch"
    
    <?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>
        <KeywordSearch xmlns="https://www.somewebsite.com/">
      <searchTerm>string</searchTerm>
      <resultsReturned>int</resultsReturned>
       </KeywordSearch>
      </soap:Body>
    </soap:Envelope>
    

    Response:

    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    
    <?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>
        ...some stuff...
      </soap:Body>
    </soap:Envelope>
    

    So, what is the right, or at least most logical way to built this simple client? What tools/libraries/methodologies would you suggest to newbie (assuming VS 2010 C#, .NET 4.0 environment)?

  • rita
    rita over 13 years
    It looks simple enough. Thanks! i'll give it a try.
  • marc_s
    marc_s over 13 years
    @rita: See! WCF isn't that big scary monster after all ;-) Just learn it bit by bit, as much of it as you need right now - and it all starts to make sense :-)