I just want to make a SOAP request!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HaLo2FrEeEk
    Contributor
    • Feb 2007
    • 404

    I just want to make a SOAP request!

    Why is it so difficult?!?

    Ok, Bungie has created an API for their new game, Halo Reach. The API allows you to access details stats and information about the game. There are two endpoints, JSON and SOAP. I figured that since SOAP was already XML that it would be easier to get that file than to translate the JSON into usable data. I think I was wrong.

    I cannot figure out how to make a SOAP request using C#. When I just use a regular old HttpWebRequest/HttpWebResponse , I get an error "400 (Bad Request)."

    Can someone please help me figure this out, or tell me if it would just be easier to use JSON.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Right click on References, and click Add Service Reference:



    Put in the address to the service, click Go, and name the service once it's found.

    That will create service client code in your project. Depending on what type of service it is, the code will vary a bit.

    If you post the address to the SOAP service, I can give some more details.

    Comment

    • HaLo2FrEeEk
      Contributor
      • Feb 2007
      • 404

      #3
      I did that, but all of the guides that I found online told me to put in:



      I've never used SOAP before so I didn't know what to do.

      I just put in the service reference for the SOAP service and it came up with all of the methods available. Here is the address:



      You won't be able to actually make a calls without an API key though, and you have to pay for one of those.

      Unfortunately I'm stll having a problem. In the service reference it lists all of the available methods, and I named the reference "ReachAPI", but when I do ReachAPI., it doesn't have any of the methods listed, I can't figure out how to access them.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        These screenshots should give you a slightly more detailed idea of what's going on:





        Note what I called the service. You can call it anything you'd like, but that becomes the namespace (that I highlighted in the second image).

        To use the service, you have to create a client. this service is called ReachApiSoap, so the client is ReachApiSoapCli ent. Then you use the client to make method calls.

        You can also set it up to generate Asynchronous methods, which execute on a separate thread, and call a method back when they're done.

        Hope this helps.

        Comment

        • Ebenezer Ampadu

          #5
          1.You will need a new instance of Visual Studio 2010 or Visual Web Developer running.
          2.Create a new project using the Web Services Template.
          3.In solution explorer, you could choose to rename the IService.cs and the Service.cs files, and also rename the Service and IService classes. Create the SOAP methods. I believe you know how to do that. In the Service.svc file, configure or change the names of the Service attribute to match the name of the Service class and also alter the name of code_behind attribute to match the name of the Service.cs file.
          4.In the Web.config file, configure the endpoint to use wsHttp.
          5.On the File menu, click save all.
          6.Right click the Service.svc file in Solution Explorer and click View in Browser to view the SOAP Web Service.
          7.A piece of class code would show you how to create the proxy. Record the http://localhost:portNumber/Namespace/Service.sc information.
          8.Now open your WPF project in a new instance of Visual Studio or Express Edition.
          9.Right click the project in Solution Explorer and click Add Service Reference.
          10. Enter the address you recorded and enter the namespace name in the Namespace field and click OK.
          11.When your SOAP Web Service appears in the Dialog box, highlight it and click OK. The Web Service should be added to your WPF Project.
          12.Append a Using directive as your "WPF project name.Your Soap Web Service";
          13.Create the proxy and begin calling the SOAP functions.
          I hope this suffices.

          Comment

          Working...