MrMain
asked on
SoapHeader Authentication of Webservice throws NullReferenceException ...
Hi,
I am attempting to pass a user id and pw in a Soapheader for my web service. I am getting the following exception :
System.Web.Services.Protoc ols.SoapEx ception: Server was unable to process request. ---> System.NullReferenceExcept ion: Object reference not set to an instance of an object. at ImageWebService..ctor() --- End of inner exception stack trace
I have used the SOAP Trace utlity to capture the SoapHeader, you can see that I have populated the username and password params.
<?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>
- <AuthHeader xmlns="http://localhost/webservices/webservices">
<Username>username</Userna me>
<Password>password</Passwo rd>
</AuthHeader>
</soap:Header>
- <soap:Body>
<GetTime xmlns="http://localhost/webservices/webservices" />
</soap:Body>
</soap:Envelope>
Here are the relevant parts of my webservice :
[WebService(Namespace="http://localhost/webservices/webservices")]
public class WebService : System.Web.Services.WebSer vice
{
public AuthHeader AuthenticationHeader;
....
public class AuthHeader : SoapHeader
{
public string Username;
public string Password;
}
[WebMethod, SoapHeader( "AuthenticationHeader" )]
public string GetTime()
{
try
{
return DateTime.Now.ToString("HH. mm.ss.ffff ff") + " Credentials : " + AuthenticationHeader.Usern ame + ":" + AuthenticationHeader.Passw ord;
}catch (Exception e) {
return "Exception from GetTime()" + e.Message;
}
}
My Client code :
WebService myService = new WebService();
AuthHeader objAuthHeader = new AuthHeader();
objAuthHeader.Username = "username";
objAuthHeader.Password = "password";
myService.AuthHeaderValue = objAuthHeader;
string message = myImgService.GetTime();
I am not sure why I am getting this exception, or how to fix it ?
Thanks.
I am attempting to pass a user id and pw in a Soapheader for my web service. I am getting the following exception :
System.Web.Services.Protoc
I have used the SOAP Trace utlity to capture the SoapHeader, you can see that I have populated the username and password params.
<?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>
- <AuthHeader xmlns="http://localhost/webservices/webservices">
<Username>username</Userna
<Password>password</Passwo
</AuthHeader>
</soap:Header>
- <soap:Body>
<GetTime xmlns="http://localhost/webservices/webservices" />
</soap:Body>
</soap:Envelope>
Here are the relevant parts of my webservice :
[WebService(Namespace="http://localhost/webservices/webservices")]
public class WebService : System.Web.Services.WebSer
{
public AuthHeader AuthenticationHeader;
....
public class AuthHeader : SoapHeader
{
public string Username;
public string Password;
}
[WebMethod, SoapHeader( "AuthenticationHeader" )]
public string GetTime()
{
try
{
return DateTime.Now.ToString("HH.
}catch (Exception e) {
return "Exception from GetTime()" + e.Message;
}
}
My Client code :
WebService myService = new WebService();
AuthHeader objAuthHeader = new AuthHeader();
objAuthHeader.Username = "username";
objAuthHeader.Password = "password";
myService.AuthHeaderValue = objAuthHeader;
string message = myImgService.GetTime();
I am not sure why I am getting this exception, or how to fix it ?
Thanks.
The inner exception message cites the constructor of an ImageWebService class, but I don't see that class mentioned anywhere else. Does any of your code reference a class by this name?
ASKER
Yeah - sorry, that is the name of my webservice, I just striped it out for the purpose of this question. The actual client code is :
Client code :
ImageWebService myImgService = new ImageWebService();
AuthHeader objAuthHeader = new AuthHeader();
objAuthHeader.Username = "username";
objAuthHeader.Password = "password";
myImgService.AuthHeaderVal ue = objAuthHeader;
string message = myImgService.GetTime();
The ImageWebService is the webservice that contains the SoapHeader Class and the GetTime() webmethod.
Client code :
ImageWebService myImgService = new ImageWebService();
AuthHeader objAuthHeader = new AuthHeader();
objAuthHeader.Username = "username";
objAuthHeader.Password = "password";
myImgService.AuthHeaderVal
string message = myImgService.GetTime();
The ImageWebService is the webservice that contains the SoapHeader Class and the GetTime() webmethod.
Is the ImageWebService class from a VS-generated Web Reference?
Did the error message include any suggestion of a line number within a specific file/class?
Your error message above:
System.NullReferenceExcept ion: Object reference not set to an instance of an object. at ImageWebService..ctor()
seems to suggest that the error is occuring within the ImageWebService constructor (triggered at the "new ImageWebService();" statement)...
Did the error message include any suggestion of a line number within a specific file/class?
Your error message above:
System.NullReferenceExcept
seems to suggest that the error is occuring within the ImageWebService constructor (triggered at the "new ImageWebService();" statement)...
ASKER
I dont have Visual Studio .net, I used the wsdl utlity that comes with the .net sdk to create the ImageWebService Class. Then I built the ImageWebService DLL and placed it in the same directory as my client, a C# windows application. But all this was working fine before I added this SoapHeader stuff, the soap header call even worked fine the first time I ran it... I'm not sure what I have done to break it?
The error occurs when I attempt to call the GetTime() webmethod. This is the one that has the '[WebMethod, SoapHeader( "AuthenticationHeader" )]' reference.
This is the full exception below ... it looks to be something to do with the SoapHttpClientProtocol.Inv oke() or SoapHttpClientProtocol.Rea dResponse( ) methods ?
System.Web.Services.Protoc ols.SoapEx ception: System.Web.Services.Protoc ols.SoapEx ception: Server was unable to process request. ---> System.NullReferenceExcept ion: Object reference not set to an instance of an object.
at ImageWebService..ctor()
--- End of inner exception stack trace ---
at System.Web.Services.Protoc ols.SoapHt tpClientPr otocol.Rea dResponse( SoapClient Message message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protoc ols.SoapHt tpClientPr otocol.Inv oke(String methodName, Object[] parameters)
at SytekImageService.ImageWeb Service.Ge tTime()
at WindowsApplication.Form1.b tnUploadAl bum_Click( Object sender, EventArgs evArgs)
at System.Windows.Forms.Contr ol.OnClick (EventArgs e)
at System.Windows.Forms.Butto n.OnClick( EventArgs e)
at System.Windows.Forms.Butto n.OnMouseU p(MouseEve ntArgs mevent)
at System.Windows.Forms.Contr ol.WmMouse Up(Message & m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Contr ol.WndProc (Message& m)
at System.Windows.Forms.Butto nBase.WndP roc(Messag e& m)
at System.Windows.Forms.Butto n.WndProc( Message& m)
at System.Windows.Forms.Contr olNativeWi ndow.OnMes sage(Messa ge& m)
at System.Windows.Forms.Contr olNativeWi ndow.WndPr oc(Message & m)
at System.Windows.Forms.Nativ eWindow.Ca llback(Int Ptr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microso ft.net/fra mework/v1. 1.4322/msc orlib.dll
-------------------------- ---------- ----
WindowsApplication
Assembly Version: 1.0.1764.11494
Win32 Version: 1.0.1764.11494
CodeBase: file:///C:/Documents%20and %20Setting s/Nathan%2 0Main/My%2 0Documents /Dev/C%23/ WebAlbum/R elease/Win dowsApplic ation.exe
-------------------------- ---------- ----
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl y/gac/syst em.windows .forms/1.0 .5000.0__b 77a5c56193 4e089/syst em.windows .forms.dll
-------------------------- ---------- ----
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl y/gac/syst em/1.0.500 0.0__b77a5 c561934e08 9/system.d ll
-------------------------- ---------- ----
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl y/gac/syst em.xml/1.0 .5000.0__b 77a5c56193 4e089/syst em.xml.dll
-------------------------- ---------- ----
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl y/gac/syst em.drawing /1.0.5000. 0__b03f5f7 f11d50a3a/ system.dra wing.dll
-------------------------- ---------- ----
GlacialList
Assembly Version: 1.0.1513.31776
Win32 Version: 1.0.1513.31776
CodeBase: file:///C:/Documents%20and %20Setting s/Nathan%2 0Main/My%2 0Documents /Dev/C%23/ WebAlbum/R elease/Gla cialList.D LL
-------------------------- ---------- ----
ImageWebService
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/Documents%20and %20Setting s/Nathan%2 0Main/My%2 0Documents /Dev/C%23/ WebAlbum/R elease/Ima geWebServi ce.DLL
-------------------------- ---------- ----
System.Web.Services
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl y/gac/syst em.web.ser vices/1.0. 5000.0__b0 3f5f7f11d5 0a3a/syste m.web.serv ices.dll
-------------------------- ---------- ----
System.Web
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl y/gac/syst em.web/1.0 .5000.0__b 03f5f7f11d 50a3a/syst em.web.dll
-------------------------- ---------- ----
kj9x8nz0
Assembly Version: 0.0.0.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl y/gac/syst em/1.0.500 0.0__b77a5 c561934e08 9/system.d ll
-------------------------- ---------- ----
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
The error occurs when I attempt to call the GetTime() webmethod. This is the one that has the '[WebMethod, SoapHeader( "AuthenticationHeader" )]' reference.
This is the full exception below ... it looks to be something to do with the SoapHttpClientProtocol.Inv
System.Web.Services.Protoc
at ImageWebService..ctor()
--- End of inner exception stack trace ---
at System.Web.Services.Protoc
at System.Web.Services.Protoc
at SytekImageService.ImageWeb
at WindowsApplication.Form1.b
at System.Windows.Forms.Contr
at System.Windows.Forms.Butto
at System.Windows.Forms.Butto
at System.Windows.Forms.Contr
at System.Windows.Forms.Contr
at System.Windows.Forms.Butto
at System.Windows.Forms.Butto
at System.Windows.Forms.Contr
at System.Windows.Forms.Contr
at System.Windows.Forms.Nativ
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microso
--------------------------
WindowsApplication
Assembly Version: 1.0.1764.11494
Win32 Version: 1.0.1764.11494
CodeBase: file:///C:/Documents%20and
--------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl
--------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl
--------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl
--------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl
--------------------------
GlacialList
Assembly Version: 1.0.1513.31776
Win32 Version: 1.0.1513.31776
CodeBase: file:///C:/Documents%20and
--------------------------
ImageWebService
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/Documents%20and
--------------------------
System.Web.Services
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl
--------------------------
System.Web
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl
--------------------------
kj9x8nz0
Assembly Version: 0.0.0.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembl
--------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
Well, the wsdl utlity and the VS.NET "Web Reference" both generate the same Web method proxy class...
I take it you didn't do anything to modify the class's code after generating it via wsdl?
I take it you didn't do anything to modify the class's code after generating it via wsdl?
ASKER
yeah - they would I guess.
I modified it once to capture the soap header to make sure I was sending the correct stuff. But I re-create my proxy class with wsdl everytime I make a change to the webservice. So any changes I made have long gone.
I modified it once to capture the soap header to make sure I was sending the correct stuff. But I re-create my proxy class with wsdl everytime I make a change to the webservice. So any changes I made have long gone.
ASKER
This is my proxy class :
//------------------------ ---------- ---------- ---------- ---------- ---------- ----
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------ ---------- ---------- ---------- ---------- ---------- ----
//
// This source code was auto-generated by wsdl, Version=1.1.4322.573.
//
namespace SytekImageService {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protoc ols;
using System.ComponentModel;
using System.Web.Services;
/// <remarks/>
[System.Diagnostics.Debugg erStepThro ughAttribu te()]
[System.ComponentModel.Des ignerCateg oryAttribu te("code") ]
[System.Web.Services.WebSe rviceBindi ngAttribut e(Name="Im ageWebServ iceSoap", Namespace="http://localhost/webservices/webservices")]
public class ImageWebService : System.Web.Services.Protoc ols.SoapHt tpClientPr otocol {
public AuthHeader AuthHeaderValue;
/// <remarks/>
public ImageWebService() {
this.Url = "http://localhost/webservices/ImageWebService.asmx";
}
/// <remarks/>
[System.Web.Services.Proto cols.SoapD ocumentMet hodAttribu te("http://localhost/webservices/webservices/SaveImage", RequestNamespace="http://localhost/webservices/webservices", ResponseNamespace="http://localhost/webservices/webservices", Use=System.Web.Services.De scription. SoapBindin gUse.Liter al, ParameterStyle=System.Web. Services.P rotocols.S oapParamet erStyle.Wr apped)]
public string SaveImage([System.Xml.Seri alization. XmlElement Attribute( DataType=" base64Bina ry")] System.Byte[] aImage, string strAlbumPath, string strImageName) {
object[] results = this.Invoke("SaveImage", new object[] {
aImage,
strAlbumPath,
strImageName});
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginSaveImage(System.Byte [] aImage, string strAlbumPath, string strImageName, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("SaveImag e", new object[] {
aImage,
strAlbumPath,
strImageName}, callback, asyncState);
}
/// <remarks/>
public string EndSaveImage(System.IAsync Result asyncResult) {
object[] results = this.EndInvoke(asyncResult );
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto cols.SoapD ocumentMet hodAttribu te("http://localhost/webservices/webservices/CreateDirectory", RequestNamespace="http://localhost/webservices/webservices", ResponseNamespace="http://localhost/webservices/webservices", Use=System.Web.Services.De scription. SoapBindin gUse.Liter al, ParameterStyle=System.Web. Services.P rotocols.S oapParamet erStyle.Wr apped)]
public string CreateDirectory(string strDirectory) {
object[] results = this.Invoke("CreateDirecto ry", new object[] {
strDirectory});
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginCreateDirectory(strin g strDirectory, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("CreateDi rectory", new object[] {
strDirectory}, callback, asyncState);
}
/// <remarks/>
public string EndCreateDirectory(System. IAsyncResu lt asyncResult) {
object[] results = this.EndInvoke(asyncResult );
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto cols.SoapD ocumentMet hodAttribu te("http://localhost/webservices/webservices/UploadFile", RequestNamespace="http://localhost/webservices/webservices", ResponseNamespace="http://localhost/webservices/webservices", Use=System.Web.Services.De scription. SoapBindin gUse.Liter al, ParameterStyle=System.Web. Services.P rotocols.S oapParamet erStyle.Wr apped)]
public string UploadFile([System.Xml.Ser ialization .XmlElemen tAttribute (DataType= "base64Bin ary")] System.Byte[] aFileBytes, string strPathToFile, string strFileName) {
object[] results = this.Invoke("UploadFile", new object[] {
aFileBytes,
strPathToFile,
strFileName});
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginUploadFile(System.Byt e[] aFileBytes, string strPathToFile, string strFileName, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("UploadFi le", new object[] {
aFileBytes,
strPathToFile,
strFileName}, callback, asyncState);
}
/// <remarks/>
public string EndUploadFile(System.IAsyn cResult asyncResult) {
object[] results = this.EndInvoke(asyncResult );
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto cols.SoapD ocumentMet hodAttribu te("http://localhost/webservices/webservices/Login", RequestNamespace="http://localhost/webservices/webservices", ResponseNamespace="http://localhost/webservices/webservices", Use=System.Web.Services.De scription. SoapBindin gUse.Liter al, ParameterStyle=System.Web. Services.P rotocols.S oapParamet erStyle.Wr apped)]
public string Login() {
object[] results = this.Invoke("Login", new object[0]);
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginLogin(System.AsyncCal lback callback, object asyncState) {
return this.BeginInvoke("Login", new object[0], callback, asyncState);
}
/// <remarks/>
public string EndLogin(System.IAsyncResu lt asyncResult) {
object[] results = this.EndInvoke(asyncResult );
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto cols.SoapH eaderAttri bute("Auth HeaderValu e", Direction=System.Web.Servi ces.Protoc ols.SoapHe aderDirect ion.InOut) ]
[System.Web.Services.Proto cols.SoapD ocumentMet hodAttribu te("http://localhost/webservices/webservices/GetTime", RequestNamespace="http://localhost/webservices/webservices", ResponseNamespace="http://localhost/webservices/webservices", Use=System.Web.Services.De scription. SoapBindin gUse.Liter al, ParameterStyle=System.Web. Services.P rotocols.S oapParamet erStyle.Wr apped)]
public string GetTime() {
object[] results = this.Invoke("GetTime", new object[0]);
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginGetTime(System.AsyncC allback callback, object asyncState) {
return this.BeginInvoke("GetTime" , new object[0], callback, asyncState);
}
/// <remarks/>
public string EndGetTime(System.IAsyncRe sult asyncResult) {
object[] results = this.EndInvoke(asyncResult );
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto cols.SoapD ocumentMet hodAttribu te("http://localhost/webservices/webservices/generateOID", RequestNamespace="http://localhost/webservices/webservices", ResponseNamespace="http://localhost/webservices/webservices", Use=System.Web.Services.De scription. SoapBindin gUse.Liter al, ParameterStyle=System.Web. Services.P rotocols.S oapParamet erStyle.Wr apped)]
public string generateOID() {
object[] results = this.Invoke("generateOID", new object[0]);
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BegingenerateOID(System.As yncCallbac k callback, object asyncState) {
return this.BeginInvoke("generate OID", new object[0], callback, asyncState);
}
/// <remarks/>
public string EndgenerateOID(System.IAsy ncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult );
return ((string)(results[0]));
}
}
/// <remarks/>
[System.Xml.Serialization. XmlTypeAtt ribute(Nam espace="http://localhost/webservices/webservices") ]
[System.Xml.Serialization. XmlRootAtt ribute(Nam espace="http://localhost/webservices/webservices", IsNullable=false)]
public class AuthHeader : System.Web.Services.Protoc ols.SoapHe ader {
/// <remarks/>
public string Username;
/// <remarks/>
public string Password;
}
}
//------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.573
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------
//
// This source code was auto-generated by wsdl, Version=1.1.4322.573.
//
namespace SytekImageService {
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services.Protoc
using System.ComponentModel;
using System.Web.Services;
/// <remarks/>
[System.Diagnostics.Debugg
[System.ComponentModel.Des
[System.Web.Services.WebSe
public class ImageWebService : System.Web.Services.Protoc
public AuthHeader AuthHeaderValue;
/// <remarks/>
public ImageWebService() {
this.Url = "http://localhost/webservices/ImageWebService.asmx";
}
/// <remarks/>
[System.Web.Services.Proto
public string SaveImage([System.Xml.Seri
object[] results = this.Invoke("SaveImage", new object[] {
aImage,
strAlbumPath,
strImageName});
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginSaveImage(System.Byte
return this.BeginInvoke("SaveImag
aImage,
strAlbumPath,
strImageName}, callback, asyncState);
}
/// <remarks/>
public string EndSaveImage(System.IAsync
object[] results = this.EndInvoke(asyncResult
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto
public string CreateDirectory(string strDirectory) {
object[] results = this.Invoke("CreateDirecto
strDirectory});
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginCreateDirectory(strin
return this.BeginInvoke("CreateDi
strDirectory}, callback, asyncState);
}
/// <remarks/>
public string EndCreateDirectory(System.
object[] results = this.EndInvoke(asyncResult
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto
public string UploadFile([System.Xml.Ser
object[] results = this.Invoke("UploadFile", new object[] {
aFileBytes,
strPathToFile,
strFileName});
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginUploadFile(System.Byt
return this.BeginInvoke("UploadFi
aFileBytes,
strPathToFile,
strFileName}, callback, asyncState);
}
/// <remarks/>
public string EndUploadFile(System.IAsyn
object[] results = this.EndInvoke(asyncResult
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto
public string Login() {
object[] results = this.Invoke("Login", new object[0]);
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginLogin(System.AsyncCal
return this.BeginInvoke("Login", new object[0], callback, asyncState);
}
/// <remarks/>
public string EndLogin(System.IAsyncResu
object[] results = this.EndInvoke(asyncResult
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto
[System.Web.Services.Proto
public string GetTime() {
object[] results = this.Invoke("GetTime", new object[0]);
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BeginGetTime(System.AsyncC
return this.BeginInvoke("GetTime"
}
/// <remarks/>
public string EndGetTime(System.IAsyncRe
object[] results = this.EndInvoke(asyncResult
return ((string)(results[0]));
}
/// <remarks/>
[System.Web.Services.Proto
public string generateOID() {
object[] results = this.Invoke("generateOID",
return ((string)(results[0]));
}
/// <remarks/>
public System.IAsyncResult BegingenerateOID(System.As
return this.BeginInvoke("generate
}
/// <remarks/>
public string EndgenerateOID(System.IAsy
object[] results = this.EndInvoke(asyncResult
return ((string)(results[0]));
}
}
/// <remarks/>
[System.Xml.Serialization.
[System.Xml.Serialization.
public class AuthHeader : System.Web.Services.Protoc
/// <remarks/>
public string Username;
/// <remarks/>
public string Password;
}
}
ASKER
I found the problem… I added the following to initialise a session variable :
public ImageWebService()
{
// Initialize the logged in value to false.
HttpContext.Current.Sessio n["loggedI n"] = false;
}
If I remove the HttpContext line then it works, I dont know why though.
Thanks heaps for your time.
public ImageWebService()
{
// Initialize the logged in value to false.
HttpContext.Current.Sessio
}
If I remove the HttpContext line then it works, I dont know why though.
Thanks heaps for your time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah - I looked into it. You get a nullReferenceException if you dont add '[WebMethod(EnableSession= true)]' to your webmethod. Since I was calling 'HttpContext.Current.Sessi on["logged In"] = false;
' in my constructor that is why the exception was coming from there. It was strange that my constructor was not called until I called the GetTime() test webmethod, and not when I was calling 'new' on the webservice proxy class???
Thanks again.
' in my constructor that is why the exception was coming from there. It was strange that my constructor was not called until I called the GetTime() test webmethod, and not when I was calling 'new' on the webservice proxy class???
Thanks again.
What SOAP Trace utlity did you use? Thanks for your help.
ASKER
I haven't done any of this kind of work for a little while, but I think what you need to do is turn on tracing or allow tracing to be displayed in your asp.net config file (web.config) in the same directory as your asp.net application. This should allow ASP.NET Tracing and exceptions to be displayed for the current asp.net application.