Ashish Ojha

Hi ,

I am calling a web service (the web service is in j2ee) from my .net client.

Firstly i need to call a method 'login' from the web service , this
method will return a token to meNow , i need to set this token in the

header to call another method on the same web service.
I am able to call the web method and get the token but do not know how to set
this token in the header to call another method. HELP !

regards,

Ashish.0.



Re: Architecture General Settinh header to call web method - Urgent

Ollie Riches

check out the following links, these should help you

http://www.devpapers.com/article/23

http://msdn2.microsoft.com/en-us/library/system.web.services.protocols.soapheader.aspx

HTH

Ollie Riches






Re: Architecture General Settinh header to call web method - Urgent

LivetoCodeCodetoLive!

<%@ WebService Language="C#" Class="MyWebService"%>
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
using System;

// Define a SOAP header by deriving from the SoapHeader base class.

public class MyHeader : SoapHeader {
public string MyValue;
}

public class MyWebService {

public MyHeader myHeader;
// Receive all SOAP headers besides the MyHeader SOAP header.
public SoapUnknownHeader[] unknownHeaders;

[WebMethod]
[SoapHeader("myHeader", Direction=SoapHeaderDirection.InOut)]

//Receive any SOAP headers other than MyHeader.
[SoapHeader("unknownHeaders",Required=false)]

public string MyWebMethod() {

foreach (SoapUnknownHeader header in unknownHeaders) {
// Perform some processing on the header.
if (header.Element.Name == "MyKnownHeader")
header.DidUnderstand = true;
else
// For those headers that cannot be
// processed, set the DidUnderstand property to false.
header.DidUnderstand = false;
}
return "Hello";
}
}

This is code I found on MSDN.






Re: Architecture General Settinh header to call web method - Urgent

LivetoCodeCodetoLive!

Thanks a lot, I just realized that the second link that Ollie sent contains this code, I was going through the thread and found this code, I did my search and found this link also but I didn't realize it at the time.






Re: Architecture General Settinh header to call web method - Urgent

Ashish Ojha

Thanks for your quick responses.

However , am still facing some issues. The web service (is in j2ee) does not have any soapheader definition.It is using wsdd instead of wsdl.

When I make a web service in .net as suggested above i can set the header while incase of the j2ee web service am callin , there is no soapheader class.

Am i missing something Suggestions urgently needed.

Client code :

============================

Public Function loginME() As String

Dim w As New creek.UserServiceProviderService ' this is the j2EE web service - added through web reference

Dim w_str As String

Try

w_str = w.login("test", "111111") ' a method @ webservice which returns the token value.

w.lockUser("sujit.emp1006") ' now i need to put w_str as a token header like 'token=w_str' in header and call this method

Catch ex As Exception

Return ex.Message

Exit Function

End Try

Return w_str

End Function

==================================