locked
Receiving a SOAP Message RRS feed

  • Question

  • User1975998971 posted

    I have a client that is sending us a SOAP Request and provided us with a WSDL.  I believe this is the WSDL for what our service should look like.  Basically all it is supposed to do is we receive the message and send a message back stating we received the message nothing more.

    When I asked for clarification I got this response:

    The simple workflow for outbound uses the simple WSDL, which I will attach to the ticket. You need to set up the service on your end to respond to OUR send_message requests as soon as they are sent. For simple workflow there is nothing that needs to be initiated from your service, only a response to our send_message.

    Am I correct in believing that I am creating the service with one main method which is send_message which will have a variable of HTTPRequest in which we handle it and then use the POST message stating we received it or I might be not understanding.

    When I looked for a way to generate a service from a WSDL it said to use the Add Service Reference.  So I did, but I am not sure where to go from there.

    Any help would be appreciated.

    Tuesday, March 11, 2014 3:40 PM

Answers

  • User-417640953 posted

    Am I correct in believing that I am creating the service with one main method which is send_message which will have a variable of HTTPRequest in which we handle it and then use the POST message stating we received it or I might be not understanding.

    Hi jesalynolson,

    Thanks for your post.

    If you want to call the wcf service using HttpWebRequest in the asp.net application, I think you should create the

    soap message string like below.

      string param = @"<?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>
                                                <GetData xmlns=""http://tempuri.org/"">
                                                  <value>123</value>
                                                </GetData>
                                              </soap:Body>
                                            </soap:Envelope>";
                    byte[] bs = Encoding.UTF8.GetBytes(param);
                    HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost:54875/Service1.svc?wsdl");
    
                    myRequest.Method = "POST";
                    myRequest.ContentType = "text/xml;charset=utf-8";
                    myRequest.Headers.Add("SOAPAction", "http://tempuri.org/IService1/GetData");
                    myRequest.ContentLength = bs.Length;
    
                    using (Stream reqStream = myRequest.GetRequestStream())
                    {
                        reqStream.Write(bs, 0, bs.Length);
                    }
                    using (HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse())
                    {
                        StreamReader mysr = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
                        string responseResult = mysr.ReadToEnd();
                        Response.Write("Result:" + responseResult);
                    }
    

    When I looked for a way to generate a service from a WSDL it said to use the Add Service Reference.  So I did, but I am not sure where to go from there.

    If you want to use the svcutil.exe generate service proxy in visual studio by adding service reference, please right click the project in Visual Studio solution explorer.

    Then click "Add service reference" and input the wsdl address. That will create a service proxy class in your project. So you can call service using the service proxy.

    Hope that helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 13, 2014 2:02 AM