473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

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.
dt****@cam-co.org


//---------- 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="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<soap:Header>
<SecurityCookie xmlns="http://some.site.com/security">
...
</SecurityCookie>
</soap:Header>
<soap:Body>
<doSomething xmlns="urn:doSomethingNS">
<Code>VU</Code>
<status>Valid</status>
<ID>43195538</ID>
</doSomething>
</soap:Body>
</soap:Envelope>

//---------- Java Client SOAP envelope -- This message will work
-----------------------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:SecurityCookie
soapenv:mustUnderstand="0"
xsi:type="xsd:string"
xmlns:ns1="http://some.site.com/security">
...
</ns1:SecurityCookie>
</soapenv:Header>
<soapenv:Body>
<doSomething xmlns="urn:doSomethingNS">
<Code>VU</Code>
<status>VALID</status>
<ID>1845041</ID>
</doSomething>
</soapenv:Body>
</soapenv:Envelope>
// ------------ 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.Diagnostics.DebuggerStepThroughAttribute()]
[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 = "http://some.site.com/doSomething";
}

/// Function call for the method to call the web service.
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
RequestNamespace="urn:doSomethingNS",
ResponseNamespace="urn:doSomethingNS",
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")]
[Trace(Filename="C:\\TraceLog\\SoapTraceLog.log")]
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="http://some.site.com/security", IsNullable=false,
DataType="String")]
public class securityCookie : System.Web.Services.Protocols.SoapHeader
{
//[System.Xml.Serialization.XmlTextAttribute]
public string SecurityCookieString;
}

Nov 23 '05 #1
0 4640

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anand Natrajan | last post by:
Hi! I have a VB .NET client that is accessing an rpc/encoded service deployed in Axis 1.2. One of the operations, whoami, returns a string array. The server-side Java signature of this method is...
6
by: john deviney | last post by:
I have a C#/.Net 1.1 client talking to a Java based web service. I need to insert a soap header on the client side which is expected on the server side. Currently, the Java ws provider, Axis, does...
0
by: jennifer.perkins | last post by:
I've seen a couple posts by people having similar problems, but the suggested solutions I've tried so far haven't worked. I'm using a SOAP client in VB.Net (constructed by wsdl.exe) and the...
3
by: Dhananjayan | last post by:
Hi, I have a java webservice running on Axis, Iam able to create a java client to invoke the webservice and obtain the result. But iam not able to invoke the service from .Net client.. Here are...
7
by: Jamie Phillips | last post by:
I'm sure this topic has been "around the block" a few times, but I have not been able to find ANY solutin that fits this particular problem. I have written a Java Axis web service that has a method...
5
by: vthakur | last post by:
Hello: I have a Axis Web Service that sets the sessionid in the SOAP header for persisting the session. The client is a .Net client that processes the header as an Unknown Header. It sets the...
3
by: GT | last post by:
I have a .NET client that consumes an Axis web service. A change was made recently to the AXIS web service, and ever since then my .NET proxy class has been throwing an InvalidCastException. The...
0
by: karazy | last post by:
I have been reading all the forums and understand whats going wrong but am not sure how to fix it. I have written a basic doc/literal web service. But when it is called by a .net client it will...
2
by: David R | last post by:
I am writing a .NET web services client that is calling an Axis web service. I have two questions. 1. The following code should set the authentication; when I call a method on the web service,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.