Domanda

I am adding a .cs (Class) file and using a Web Reference in it:

using ServiceMemberIDSS;

When I type in the following code, I get on the return value of _authHeader:

private Authorization IDSSCredentials()
{
    ServiceMemberIDSS.AuthorizeHeader _authHeader = new AuthorizeHeader();
    _authHeader.UserName = "theUserName";
    _authHeader.Password = "thePassword";
    return _authHeader;
}

The _authHeader tag at the end where it is being returned at is underlined in red and says this when I hover over it:

Cannot implicitly convert type 'ServiceMemberIDSS.AuthorizeHeader' to 'System.Net.Authorization'

How can this be fixed? I need to send the Username and Password to the service before it will give a response.

AuthorizeHeader is defined in the Members.wsdl file within the App_WebReferences folder as XML, as follows:

<s:element name="AuthorizeHeader" type="tns:AuthorizeHeader" />
  <s:complexType name="AuthorizeHeader">
    <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string" />
    </s:sequence>
    <s:anyAttribute />
  </s:complexType>
È stato utile?

Soluzione

Just qualify the return type and the new() with the namespace. Like so.

private ServiceMemberIDSS.AuthorizeHeader IDSSCredentials()

    ServiceMemberIDSS.AuthorizeHeader _authHeader = new ServiceMemberIDSS.AuthorizeHeader();

    _authHeader.UserName = "theUserName";
    _authHeader.Password = "thePassword";
    return _authHeader;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top