'How can I send the adress and EndPointConfiguration to my SoapClient properly?
I have this code in my controller:
WSHttpBinding binding = new WSHttpBinding(SecurityMode.TransportWithMessageCredential);
string address = "MyWSDLUrl";
SoapClient client = new SoapClient(address, null);
ZWsCustomerInvoiceGetList zWsCustomerInvoiceGetList = new ZWsCustomerInvoiceGetList();
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
client.ClientCredentials.Windows.ClientCredential.Domain = "";
client.ClientCredentials.Windows.ClientCredential.UserName = userN;
client.ClientCredentials.Windows.ClientCredential.Password = _pasw;
client.ClientCredentials.UserName.UserName = userN;
client.ClientCredentials.UserName.Password = _pasw;
client.ChannelFactory.CreateChannel();
I have this code in my Reference.cs:
public SoapClient(string Address, EndpointConfiguration endpointConfiguration) :
base(SoapClient.GetBindingForEndpoint(endpointConfiguration), SoapClient.GetEndpointAddress(Address))
{
this.Endpoint.Name = endpointConfiguration.ToString();
ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
}
This is my error:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
I understand that is because I am sending Null to SoapClient, but I don´t know what to send for EndPointConfiguration. All what I found in forums is send all this from Headers but i don´t have them.
Also I don´t know what to send in "domain". Is the same address? Or EndPoint?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
