By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,581 Members | 1,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,581 IT Pros & Developers. It's quick & easy.

.Net client having problems w/SOAP Header to Axis WS

P: n/a
I am having a problem with formatting a SOAP Header in a .Net client. The
client calls a Java Axis 1.1 based web service. In order to authenticate the
caller, the web service call is intercepted by another web service that
validates a security token in the header.

I have pasted my current SOAP message that my code sends as captured from a
trace function that I added. Below that is a sample SOAP message that the
developer of the web service provided. The second message was generated from
a Java Client that they used for testing.

From what I can see, the biggest differences in the header is that the Java
Client explicitly defines the security token as: xsi:type="xsd:string"
Secondarily, the Java client also specifies that the web service does not
need to understand the header
by using the following attribute: soapenv:mustUnderstand="0"

I am looking for what to add/change in the C# code that invokes the web
service to attempt to match the SOAP message that works. The C# code is also
pasted below.

Any suggestions would be appreciated.

Thanks in advance,

Daniel Thune, MCSE
Systems Engineer
Control Application and Maintenance, Inc.

//---------- MS.NET Client SOAP envelope -- this fails because the header
is not processed correctly -----------------------
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap=""

<SecurityCookie xmlns="">
<doSomething xmlns="urn:doSomethingNS">

//---------- Java Client SOAP envelope -- This message will work
<soapenv:Envelope xmlns:soapenv=""
<doSomething xmlns="urn:doSomethingNS">
// ------------ C# client code

using System;
using System.Web;
using System.Xml;
using System.IO;
using System.Diagnostics;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Web.Services;
using System.Web.Services.Protocols;
/// <remarks/>
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Web.Services.WebServiceBindingAttribute(Nam e="doSomethingSoapBinding", Namespace="urn:doSomethingNS")]
public class doSomethingService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol
/// <summary>
/// securityCookie SoapHeader for authentication
/// </summary>

public securityCookie SecurityCookie;
/// Generated Method to call the web service.
public doSomethingService()
this.Url = "";

/// Function call for the method to call the web service.
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
Use=System.Web.Services.Description.SoapBindingUse .Literal,

ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("doSo methingReturn")]
[System.Web.Services.Protocols.SoapHeader("Security Cookie")]
public int
doSomething([System.Xml.Serialization.XmlElementAttribute(IsNul lable=true)]
string Code, [System.Xml.Serialization.XmlElementAttribute(IsNul lable=true)]
string status,
[System.Xml.Serialization.XmlElementAttribute(IsNul lable=true)] string ID)
object[] results = this.Invoke("doSomething", new object[] { Code, status,
ID} );
return ((int)(results[0]));

/// generated function to start an asynchronous call to the web service
public System.IAsyncResult BegindoSomething(string Code, string status,
string ID, System.AsyncCallback callback, object asyncState)
return this.BeginInvoke("doSomething", new object[] { Code, status, ID},
callback, asyncState);

/// generated function to complete an asynchronous call to the web service
public int EnddoSomething(System.IAsyncResult asyncResult)
object[] results = this.EndInvoke(asyncResult);
return ((int)(results[0]));

/// <summary>
/// this class added to define the soap header used for security.
/// the cookie will be retreived separately by the calling app
/// and inserted into the SecurityCookieString property of this class.
/// </summary>
[System.Xml.Serialization.XmlRootAttribute(ElementN ame="SecurityCookie",
Namespace="", IsNullable=false,
public class securityCookie : System.Web.Services.Protocols.SoapHeader
public string SecurityCookieString;

Nov 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.