.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Parsing out result from SOAP Response envelope

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :Windows Application

Hi guys,

I built the following SOAP Request method and am trying to find out the best way to parse out just the relevant result data from the response below.

    protected void Test_Click(object sender, EventArgs e)
        string oRequest = "";
        oRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:com=\"http://com.remp.web.sas.tubeorder.type\">";
        oRequest = oRequest + "<soapenv:Header/>";
        oRequest = oRequest + "<soapenv:Body>";
        oRequest = oRequest + "<com:beginTransaction>";
        oRequest = oRequest + "<Long_1>10</Long_1>";
        oRequest = oRequest + "<String_2>BARCODE</String_2>";
        oRequest = oRequest + "<String_3>TUBEFIXRACKVAR</String_3>";
        oRequest = oRequest + "</com:beginTransaction>";
        oRequest = oRequest + "</soapenv:Body>";
        oRequest = oRequest + "</soapenv:Envelope>";

        //Builds the connection to the WebService.
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://xxx.xxx.xxx.xxx:8080/tubeorder-service/jse?wsdl");
        req.Headers.Add("SOAPAction", "\"http://tempuri.org/Register\"");
        req.ContentType = "text/xml; charset=\"utf-8\"";
        req.Accept = "text/xml";
        req.Method = "POST";


View Complete Post

More Related Resource Links

set Response to client from SOAP Envelope



I have a WCF client with a custom behavior that intercepts the SOAP request. In BeforeSendRequest in the client I get the SOAP request and pass it to another WS as parameter. The other WS posts the SOAP envelope to the real service that client wants to invoke and returns the SOAP Response back to client. So in BeforeSendRequest the intermediary service returns the real SOAP response as a string back to client.

public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
      string soapResponse = myotherProxy.CallService(request.ToString());
      return null;

How can i set the returned SOAP response (soapResponse) as the real response in the client?

Hope someone can help :)

Thank you, Adrya

How to Add Custom SOAP Headers Into The Server Response Message in WSE3.0?

Hi Dear All, Assuming I am the service provider, may i know how many ways are there to insert a custom header into the server response message? So far I tried several ways, and it can be done in custom SoapFilters (by playing with SOAPEnvelope object), and SoapExtension (SOAPMessage object). Just wondering if this could be done at web service class by specifying a SOAPHeader attribute, just like adding a SOAPHeader into the SOAP request message at consumer side? If can, it might be much smarter than SoapFilter and SoapExtension.   Thanks in advance!   Best Regards, Charles

Full SOAP envelope in WCF service log

Hello, I've enabled all the wcf tracing features but I cannot see the SOAP generated for my incoming/outgoing message (on net.tcp protocol binding). This is my configuration:   <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="All" propagateActivity="true"> <listeners> <add name="wcf" /> </listeners> </source> <source name="System.IdentityModel"> <listeners> <add name="wcf" /> </listeners> </source> <source name="System.MessageLogging"> <listeners> <add name="wcf" /> </listeners> </source> <source name="System.Runtime.Serialization"> <listeners> <add name="wcf" /> </listeners> </source> </sources> <sharedListeners> <add name="wcf" type="System.Diagnostics.XmlWriterTraceListener" initializeData="wcf.svclog" /> </sharedListeners> </system.diagnostics>   .... and ....   <diagnostics> <messageLogging logEntireMessage = "true" logMalformedMessages = "true" logMessagesAtS

Printing whole SOAP envelope - how?

Hi all, Is there a way to print a full SOAP request ? It's very nice that in WCF I can only define service interface and do the implementation straight away, without caring much for processing soap envelopes etc. But for debug reasons, sometimes I'd like to get the content of the raw SOAP request that I'm processing and store it somewhere in a file. Is there an easy way to get the soap message recieved by the service (from within the operation implementation code)?

Need help in reading Soap request and response on invoking WCF client assembly

Hi All,   I'm new to WCF and i'm using .Net 3.5. I have created a library from the proxy class generated through svcutil. I'm able to succesfully invoke service methods. I was wondering how to capture the request and response soap xmls so that i could render it on browser. If you have any code piece for this kind of problem please share it with me. Regards, Rahul

Post SOAP Envelope to WCF service

Hi, I have the following SOAP message that i want to post it to my WCF Service and get response. "<s:Envelope xmlns:a=\"http://www.w3.org/2005/08/addressing\" xmlns:s=\"http://www.w3.org/2003/05/soap-envelope\">\r\n  <s:Header>\r\n    <a:Action s:mustUnderstand=\"1\">http://schemas.devleap.com/OrderService/IOrderService/InsertOrder</a:Action>\r\n    <a:MessageID>urn:uuid:4cb619b7-365b-4108-880f-b302029d03c2</a:MessageID>\r\n    <a:ReplyTo>\r\n      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>\r\n    </a:ReplyTo>\r\n  </s:Header>\r\n  <s:Body>\r\n    <InsertOrder xmlns=\"http://schemas.devleap.com/OrderService\">\r\n      <order xmlns:d4p1=\"http://schemas.devleap.com/OrderService/Order\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n        <d4p1:IdCustomer>2</d4p1:IdCustomer>\r\n        <d4p1:IdOrder>46</d4p1:IdOrder>\r\n        <d4p1:OrderItems xmlns:d5p1=\"http://schemas.devleap.com/OrderService/OrderItems\" x

How to pass response or fault soap message to other end point using WCF?


I have changed the ReplyTo and FaultTo of SOAP Message Headers in WCF ,

and I d like  the response message can be sent to other service endpoint,

I tested it,But Response Message could not be sent to other service.

How can I make it?

Thanks in advance.


Frank Xu Lei--????,????
Focus on Distributed Applications Development and EAI based on .NET




Deserialization and SOAP envelope

I've created a web service that handles a fairly complex xml request. The service uses classes that I auto-generated from the xsd to deserialize the xml. I now need handle xml requests that have SOAP envelopes. I've tried SoapReflectionImporter but it is throwing an exception 'type System.Xml.XmlElement may not be serialized with SOAP message' which is referring to collections in my auto-generated classes. Is there any way to add this functionality without having to rewrite the auto-generated classes?

Fetch raw XML for SOAP request and response inside WCF client


I've got a basis WinForms test harness that's implementing a WCF client (.NET 3.5) which calls a SOAP web service.  I need to be able to write the HTTP request and response and output the two XML documents so I can load them back into WebBrowser controls on the form.

It looks like the way to accomplish this is to implement a custom IClientMessageInspector and an IEndpointBehavior, apply the behavior to the binding and then do the work of capturing the XML inside AfterReceiveReply and BeforeSendRequest (inside IClientMessageInspector implementation).

So my questions are:

1. This seems like a rather exhaustive process, is there a more straightforward approach to doing this? 

2.  If I am on the right path, does anyone have links to related articles/code samples related to this?

3. In what I have coded so far, I am held up trying to get the behaviorExtension to register properly (inside app.config), it looks as if I must register my classes that implement behavior Extenshions in the GAC in order to make use of them, is this true? 

Thanks in advance for taking time away to help a fellow developer!

MTOM-enabled WCF service sends document inline in SOAP response


I'm running a WCF service that has messageEncoding="Mtom" in the config file. The WCF service however, in its SOAP response sends the document as a Base 64 encoded document inline and not as a <xop:include.....> reference outside the SOAP. I'm not sure what I'm doing wrong. Please guide me.


Desired Format:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: multipart/related; boundary=MIMEBoundaryurn_uuid_F862C3E04D9E35266C1256303956115; type="application/xop+xml"; start="0.urn:uuid:F862C3E04D9E35266C1256303956116@apache.org"; start-info="application/soap+xml"; action="urn:ihe:iti:2007:RetrieveDocumentSetResponse"
Date: Fri, 23 Oct 2009 13:19:11 GMT

Content-Type: application/xop+xml; charset=UTF-8; type=&

Customize Soap Body Response in WS


Hi all,

I would like to know how i can customize the Soap Message returned by a WebService.

I have searched everywhere and I couldn't find any solution.

I have the following especification of return:

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

help parsing an xml response


I have a xml response that I receive from facebook and I am having trouble parsing it. I am not an expert at XML....

this is the response I get and it is the value of 'xmlResponse' in the procedure:

<?xml version="1.0" encoding="UTF-8"?>
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">

and I try parsing it like this:

Protected Overridable Function GetFacebookFromReader(ByVal xmlResponse As String) As FacebookShareStatDetails

Dim xmlDoc As New XmlDocument()

Dim Facebook As FacebookShareStatDetails




If xmlDoc.SelectSingleNode("link_stat") IsNot Nothing And Not String.IsNullOrEmpty(xmlDoc.SelectSingleNode("link_stat").SelectSingleNode("total_count

Soap Response mising Signature Security element + BasicHttp Binding


Hi All,

I am facing one issue with WCF service.

Issue : Response message not contains Signature Value.

if i use

TransportWithMessageCredential , the response message not contains Signature Value.But if i use only

security mode="Message" this time Response contains signature element.Why it is missing in TransportWithMessageCredential?

My configuration settings are :

Https+Messagelevel Security

Binding :TransportWithMessageCredential

    <binding name="basicHttpEndpointBinding">
     <security mode="TransportWithMessageCredential" >
      <message clientCredentialType="Certificate" />
      <transport clientCredentialType="Certificate" proxyCredentialType ="None" realm =&qu

SOAP response XML Exception



   I am using C#.Net 3.5 to consume a Web Service (http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_seq.wsdl) which has been working for me for years. About a week ago I started getting XML errors (see below for exception details) from the XML deserializer before I can even see the response from the Web Service. I used "snoop" (http://msdn2.microsoft.com/en-us/library/ms176041.aspx) to look at the XML being returned and it looks fine to me. I can even load that XML using XmlDocument.Load and I get no errors that way. Could .Net have different validation for SOAP than other xml documents? I am guessing that there is something bad happening before "snoop" can get it hands on the XML. Any idea what or what to do about

How to remove multiref- style formatting from the SOAP web service response?



I am about to write a C# web service that will replace an ATL based web service. The existing client (ATL based C++ client) needs to be working with my C# web service without changing the client codes.

Now from the WSDL from ATL web service, I noticed that it uses RPC style, so I have used SoapRpcMethodAttribute for all my web methods. Now the methods that have some out parameters and returns an array, I have taken a snap shot of the response (using Fiddler) from ATL web sever. Which looks like following:



 <?xml version="1.0" encoding="utf-8" ?> - <soap:Envelope xmlns:soap="

SOAP Client doesn't populate result object


When consuming a remote service XYZ ... XYZ_RESP = client.GET_XYZ_SERVICE(XYZ_REQUEST), the response object is set to null.  Using system.diagnostics, I can see that the results are being returned to .NET in the HttpWebResponse.


I have tried modifying the xsd as described by this link without success:




<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns="http://www.example.org" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/Enterprise/HCM/services" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="XYZ_RESP">
      <xsd:sequence maxOccurs="1">
        <xsd:element name="LOVS">
              <xsd:element name="LOV">

Soap cs code from WSDL encoding response problem


I have created a client proxy from a WSDL file with WSDL.exe

i can both send and recieve data fine.

The xmlfile i recieve contains Nordic char data (i see that in fiddler).

ex: <mydata>øæå</mydata>

The problem occurs when the data goes into my client proxy. It looks like they are in utf-8 format (and that will not work with nordic chars).

so the nordic chars are just scrambled.

any way to override this ?

 object[] response = this.Invoke("Query", new object[] { message });
 message = ((elements)(response[1]));
 return (string)(response[0]);




ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend