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

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

SOAP WS: Why do I need to HTML encode a part of the SOAP body ?

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

I am implementing a Client Web Service call to a SOAP Web Service implemented using .NET.
I am happy with what I send, e.g.:

POST /publicws/query.asmx HTTP/1.1
Host: www.blablabla.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.blablabla.com/WebServices/Query"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <Query xmlns="http://www.blablabla.com/WebServices/Query">
But, I get an error response:

  <faultstring>Server was unable to read request. --> There is an error in XML document (6, 2). --> 'Element' is an invalid node type. Line 6, position 2.</faultstring>

However, by sending the following message ('<' and '>' replaced with '&lt;' and '&gt;' in a part of the message body), I get a success response:

<?xml version="1.0" encodin

View Complete Post

More Related Resource Links

Sign outgoing client request SOAP body with WSE 3.0



We currently have the code in WCF to sign the outgoing client requests' SOAP Body, however we need the same code for use with WSE 3.0.  I can't find any examples of this.  

Is it possible?  If so, does anyone have an example?

Thank you,

How to manipulate both envelpe and body of soap message


Can you please help to manipulate the both envelope and body of SOAP message. I am using MessageInspector and in the BeforeSendRequest method,  i have a request like that.

<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
    <a:Action s:mustUnderstand="1">http://www.aaaa.com/IServices/Method</a:Action>
    <Method xmlns="http://www.aaaa.com">
After manipulation i want to create a Message wwhic will have following XML:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:SOAP-SEC="http://schemas.xmlsoap.org/soap/security/2000-12">
		<a:Action s:mustUnderstand="1">http://www.aaaa.com/IServices/Method</a:Action>

How to properly create SOAP Request that has x509 signed message body and unsigned usernameToken




I'm trying to  create a .NET client that will consume AXIS WS.

Request should be signed (using x509 Signature) and after this usernametoken profile 1.0 should be attached.

Using SOAP-UI I can create Outgoing Security Policy with few steps described below:

1) Define keystore

2) Add WSS Signature entry and mark key identifier type as X509 Certificate or Binary Security Token

3) Add WSS Username entry

The order is important.

I cannot recreate SOAP request that would generate valid response.

I got "The signature or decryption was invalid" most of the time.

Here is valid SOAP Request from SOAP-UI:


 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:user="http://users.api.swd.zbp.pl"

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

Performance issue with WCF deserializing base64 strings sent in SOAP body with CRLF


We have a big performance issue with the deserialization of base64 string in a WCF Client (C#) which is calling a web service to get PDF files. This service is a third party service not in .NET.

Server side, each PDF file is returned by the third party service as a base64 string. This base64 string is "formatted" in the returned SOAP envelope with carriage return + line feed (CRLF) every 73 characters. The third party provides a wsdl + XSD to described his service.

Client side, in the DataContract generated from the XSD, the DataMember (named "img") containing the returned PDF is declared as "byte[]" (which is logic). But we noticed that at runtime, once a message arrives, a lot of time is spent client side in the "WCF Soap Stack" before getting the PDF.

So we did some tests and discovered that after changing client side the DataMember "img" from "byte[]" to "string" (+ doing a Convert.FromBase64String() on "img"), the performance is incredibly improved (it depends on the size of the PDF).

We did next create a WCF Service to emulate the third party service. To send the very same data as the third party, we did save a soap body received from this third party into a XML file (response.xml) and we loaded + deserialized this one in our service.

In this service, we did f

Urgent: help needed signing a SOAP 1.1 Message's Body+Timestamp, and send over SSL



I have a deadline that is about to whoosh by having underestimated how tricky this would turn out to be.



  • SOAP 1.1
  • WS-Security for timestamp and signing
  • signature has to be single signature made from 2 elements: body + timestamp
  • Asymmetric Algorithm: SHA1
  • Key algorithm: RSA 
  • sent over SSL
  • client has to authenticate to server via cert with well known CN=
  • Server is not .NET but Weblogic, with policies that cannot be changed.

Basically, a secure (SSL) based transport, with signing to protect against tampering as well as replay.



Seemed like a good choice at first as it has WS-Security built in.After setting up a behavior that defines client and server certs setting binding/  

Unfortunately wsHttpBinding creates a signature from too many elements in the message (Body, Action, RelatesTo, Timestamp).

There is no apparent way of controlling what gets selected as an element of the signature.  

For example: as the ws-Security headers (Timestamp, etc.) are not part of the proxy Request message class definition, and are added/injected somewhere down the line, and are no

soap:ServerServer was unable to process request. ---> A Web Part with this ID has already been added


We have a custom WebPart that we have added to a WebPart Zone in the page layout.  We can't get several of the pages to open in SPD due to this error and the ones we can get to open will duplicate the WebPart tag.

We have tried navigating to the layout through a browser by adding the ?contents=1 to the url and we get the page cannot be found or loaded error.

We also get the duplicate webpart error when we try to create a page based on that layout.We have tried everything including, downloading a copy of the layout, removing the webpart, and reuploading it, our next move is to programmatically removing the webpart from the layout.

I just want to know if there is an easier less aggressive way to remedy this problem, and if anyone else has had it.  There have been no changes to the site or the layouts for over 2 weeks and this just started happening out of the blue.


below is the tag from the page layout that we can get open.

<WebPartPages:WebPartZone id="Zone20" runat="server" title="Zone 20" frametype="None"><ZoneTemplate>
<WebParts:PageMetaTags runat="server" ID="PageMetaTags1" Title="PageMetaTags" WebPart="true" __designer:IsClosed="false" partorder="1" __WebPartId="{4B5DCA63-0BBA-4F13-A13C-17A

How to customize soap body by dot net web service


i am using dot net 2005

web services :


[WebService(Namespace = "abc.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Srijan_Hughes : System.Web.Services.WebService {

    public Srijan_Hughes () {


    [SoapDocumentMethod(ResponseElementName = "ns0:checkVLEDataResponseElement")]
       [return: XmlElement("ns0:result")]
    public string checkVLEDataElement(string vleId, string srvcCharge, string serviceName,string amountToBeDeducted)
            string _status = "";
            clsHughes ObjTransDetails = new clsHughes();
            ObjTransDetails.VLEID = vleId;
            ObjTransDetails.ServiceAmt = srvcCharge;
            ObjTransDetails.ServiceName = serviceName;

.Net Frameword 4 SOAP Web Service



We want to upgrade from VS2005 to VS2010. Before we do that, I would like some clarity about some things.


Can we build typical SOAP webservices with the 4 Framework as I could with 2.0?


Would a WCF Service allow me to have both REST/SOAP services in one application?


Is Framework 4 ONLY for REST services and I need to stick to 3.5 for SOAP?


I downloaded the free Web Developer 2010, but I cannot seem to get anywhere trying to figure this out.


Thanks for any input.





Service Station: WSE 3.0, SOAP Transports, and More


It's that time again. Time to answer some of the questions I get on a regular basis. This month I'll look at service orientation and policy-based compatibility, SOAP's transport-neutral design, and Web Services Enhancements (WSE) 3.0.

Aaron Skonnard

MSDN Magazine June 2006

MSMQ and .NET: Send MSMQ Messages Securely Across the Internet with HTTP and SOAP


When creating a distributed system you frequently need to provide for communication between two entities that are not in sync. Microsoft Message Queue Server (MSMQ) provides the kind of store-and-forward messaging in a pre-built infrastructure that can help you address these kinds of messaging needs. In the past, MSMQ was accessed using a COM wrapper. Now there's a .NET wrapper that lets you accomplish your messaging goals easily from your Framework-based code. To illustrate the use of the wrapper, the author builds a messaging application, sends MSMQ messages over the Web, and discusses messaging security.

David S. Platt

MSDN Magazine December 2003

Secure It: WS-Security and Remoting Channel Sinks Give Message-Level Security to Your SOAP Packets


As more organizations adopt XML-based Web Services, the need for message-level security has become evident. WS-Security, now supported in the Microsoft .NET Framework, addresses this need. Using the WS-Security framework, developers can implement channel sinks to intercept Remoting messages as they pass through the .NET Remoting infrastructure. The sink can read the message, change it, and pass it along. During this process, the message can be signed for added security. This article explains how to implement a Remoting channel sink that will modify the Remoting message by including a UserName token in the header, then sign the body using the token.

Neeraj Srivastava

MSDN Magazine November 2003

House of Web Services: Accessing Raw SOAP Messages in ASP.NET Web Services


Web Services exchange XML messages. Most of today's Web Service toolkits do their best to hide this fact from developers, by exposing a Web Service's behavior as method invocations against objects instead.

Tim Ewald

MSDN Magazine March 2003

DIME: Sending Files, Attachments, and SOAP Messages Via Direct Internet Message Encapsulation


Direct Internet Message Encapsulation (DIME) is a new specification for sending and receiving SOAP messages along with additional attachments, like binary files, XML fragments, and even other SOAP messages, using standard transport protocols like HTTP. In this article, the author explains what DIME is and how it differs from MIME encapsulation. A detailed description of the message format and how it is parsed, as well as working with SOAP and extending it with WSDL, is also included.

Jeannine Hall Gailey

MSDN Magazine December 2002

SOAP: Using ATL Server to Build an Asynchronous SOAP Client in Unmanaged C++


SOAP opens up a new world of Web Services, letting you make function calls across a network or the Internet. But this flexibility creates new problems when your app needs to wait for calls to return from halfway around the world. What you need is an asynchronous SOAP client that takes advantage of threading to continue execution while waiting for calls over the wire. This article covers the basics of building such a client with ATL.

Pranish Kumar and Bogdan Crivat

MSDN Magazine April 2002

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