I am writing a C# client that calls a web service to authenticate clients. I used add service reference to add the wsdl file to my project and the proxy class generated successfully.
I am creating new instances of objects that will be used like this:
authenticateAccessPortTypeClient client = new authenticateAccessPortTypeClient();
authDetails details = new authDetails();
returnResult result = new returnResult();
This is my code when the user needs to be authenticated:
// This is details that needs to be passed in the header of the SOAP Envelope
details.key = "some key as string";
details.mode = "the mode as string";
// This is a parameter that is passed in the body of the SOAP Envelope
string memKey = "the member key as string";
result = client.authenticateAccess(details, memKey);
textBoxResult.Text = result.message;
My soap response looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="www.example.com">
<soapenv:Header/>
<soapenv:Body>
<example:authenticateAccessResponse>
<result>
<message>some string</message>
</result>
</example:authenticateAccessResponse>
</soapenv:Body>
</soapenv:Envelope>
And returnResults looks like this in the generated proxy class:
public partial class returnResult : object, System.ComponentModel.INotifyPropertyChanged {
private string messageField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
public string message {
get {
return this.messageField;
}
set {
this.messageField = value;
this.RaisePropertyChanged("message");
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
I keep on getting the error: Object reference not set to an instance of an object and returnResult is null.