我在尝试使用此Web服务https://84.199.99.213:8443/XWS/services
中的函数时遇到了一些麻烦例如,我将此标题插入信封,我可以访问所有功能。但是在我的C#代码中,无论我尝试了什么方法,我都会收到未经授权的错误或者这个例外情况,说不会理解标题。
<SOAP-ENV:Header>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' >
<Username>###</Username>
<Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>###</Password>
</UsernameToken>
</Security>
</SOAP-ENV:Header>
这是验证序列并试图在我的C#项目中使用一个函数:
// Create the binding.
WSHttpBinding myBinding = new WSHttpBinding();
myBinding.Security.Mode = SecurityMode.Transport;
myBinding.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Basic;
// Create the endpoint address.
EndpointAddress ea = new EndpointAddress("https://84.199.99.213:8443/XWS/services/cardservice");
// Create the client.
ServiceReference1.CardServiceClient cc =
new ServiceReference1.CardServiceClient(myBinding, ea);
// User name and password.
cc.ClientCredentials.UserName.UserName = "###";
cc.ClientCredentials.UserName.Password = "###";
// Open the client.
cc.Open();
//Consume a function
ServiceReference1.lookUpItem[] x = cc.listTariffs(null);
rtbOutput.Text= x.Length.ToString();
我应该在app.config中使用什么才能使其正常工作?或者是我缺少的其他东西?
有人能帮帮我吗?
提前致谢