none
Send Soap message RRS feed

  • General discussion

  • Hi, Let say I have a soap message in this variable request(This contains the soap messge) now how can I send it to www.contosa.com/CPWebService assuming this is a correct web service address.

    I dont want to add it as a web refrence. I want to learn how to use the http classes available. Please help
    • Changed type Bin-ze Zhao Tuesday, October 20, 2009 2:38 AM no follow up
    Monday, October 12, 2009 4:43 PM

All replies

  • Give one good reason why you want to do all the work yourself instead of using a generator? If you want to write the classes yourself, generate it once and use that one as an example.
    Geert van Horrik - CatenaLogic
    Visit my blog: http://blog.catenalogic.com

    Looking for a way to deploy your updates to all your clients? Try Updater!
    Tuesday, October 13, 2009 7:36 AM
  • Well, good reason may be, that he has soap message generated somewhere else or it's difficult to make code generator generate soap message, that webservice will accept (especialy if that service is written using not microsoft technologies).
    In my case worked this code:

    var url = ConfigurationManager.AppSettings["SERVICE_URL"];
    var req = (HttpWebRequest)WebRequest.Create(url);
    
    var message = generateSoap(myObject);
    
    req.ContentType = "text/xml; charset=utf-8";
    req.Method = "POST";
    req.Accept = "text/xml";
    var s = req.GetRequestStream();
    var sw = new StreamWriter(s, new UTF8Encoding(false));
    sw.Write(message);
    sw.Flush();
    sw.Close();
    s.Flush();
    s.Close();



    var resp = req.GetResponse();
    using (var sr = new StreamReader(resp.GetResponseStream()))
    {
    TracingHelper.TraceDebug("SoapMessageSender", sr.ReadToEnd()); //Just output XML response
    }




    Tuesday, October 13, 2009 7:50 AM
  • if that woked for me I wouldn't have asked this question. Am having problems using the proxy class generated by VS.

    Tuesday, October 13, 2009 1:40 PM
  • Well, you can always ask, how to make problems with proxy class go away :)
    Wednesday, October 14, 2009 5:38 AM
  • Hi,

    Could you be more clear about the problem you have for using the proxy class generated by VS?

    Thanks
    Binze
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, October 16, 2009 8:57 AM
  • Hi,

    We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.


    Thank you!
    Binze


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, October 20, 2009 2:37 AM