【发布时间】:2014-05-23 16:44:24
【问题描述】:
我是使用 .net 4.0 VS2010 的新手。我需要使用 java webservice 并发送 usernametoken 自定义身份验证来访问该服务,我在 VS2005 中使用 WSE2.0 很容易做到这一点,net 4.0 中的替代品是什么?
我的客户端是 .net 4.0 Asp.net web application(website),服务是 java webservice。
谢谢
好吧,在与谷歌叔叔核实之后,以下网站是一个很好的起点
基于此,我对代码进行了一些更改,但仍然没有太大的乐趣。这是代码
protected void TPLoginButton_Click(object sender, EventArgs e)
{
thirdpartyloginClient tplogin = null;
ThirdPartyLogInResponse proxyresponse = null;
ThirdPartyLogInRequest proxyrequest = null;
try
{
if (tplogin == null)
{
tplogin = new thirdpartyloginClient();
}
if (proxyrequest == null)
{
proxyrequest = new ThirdPartyLogInRequest();
}
tplogin.ChannelFactory.Credentials.UserName.UserName = "abcd";
tplogin.ChannelFactory.Credentials.UserName.Password = "sWwqHyCKMgjttlJEsQIvxzuBPTIBeVquZRPZqZdbDYDaOiHVxKuwYuYmQDVtqqBrBAlLiuOwWwQwOfTqSzOpyUaEbliOPaBHJTnBvulRSuZrcTHddKXwAIIxYDcuUmBJ";
proxyrequest.username = "gauls";
proxyresponse = tplogin.ThirdPartyLogIn(proxyrequest);
}
catch
{
if (proxyresponse != null)
{
ResultBoxResponse.Text = proxyresponse.result.resultMessage.ToString();
}
else
{
ResultBoxResponse.Text = "Empty response!!";
}
}
finally
{
if (proxyresponse != null)
{
ResultBoxResponse.Text = proxyresponse.result.resultMessage.ToString();
}
else
{
ResultBoxResponse.Text = "Empty response!!";
}
}
}
我的 web.config 如下所示
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="thirdpartyloginSoap11" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<!-- UsernameToken over Transport Security -->
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://11.2.2.16:6060/trydemo/ws/thirdpartylogin" binding="basicHttpBinding" bindingConfiguration="thirdpartyloginSoap11" contract="ThirdPartyLoginService.thirdpartylogin" name="thirdpartyloginSoap11"/>
</client>
</system.serviceModel>
问题是
如何添加时间戳和密码作为密码摘要
我现在得到的错误是 提供的 URI 方案“http”无效;预期的“https”。 参数名称:via
我尝试使用 clearusernamebinding
我收到以下错误
从另一方收到不安全或不正确安全的故障。故障代码和细节见内部FaultException。
我的 web.config 文件如下所示
<
system.serviceModel>
<bindings>
<clearUsernameBinding>
<binding name="myClearUsernameBinding" messageVersion="Soap11" />
</clearUsernameBinding>
</bindings>
<
client>
<
endpoint address=http://10.2.2.16:7070/demo/ws/thirdpartylogin
binding="clearUsernameBinding" bindingConfiguration="myClearUsernameBinding"
contract="ThirdPartyLoginService.thirdpartylogin"
name="ClearUsernameBinding_thirdpartylogin" />
</
client>
<
extensions>
<
bindingExtensions>
<
add name="clearUsernameBinding" type="WebServices20.BindingExtenions.ClearUsernameCollectionElement, ClearUsernameBinding" />
</
bindingExtensions>
</
extensions>
</
system.serviceModel>
“未满足摘要密码的接收者要求”strong text这是实际错误
如何在标头中将密码作为 PasswordDigest 发送?
【问题讨论】:
-
你能指出不工作的代码吗? (并给出不工作的代码)
-
我根本不知道 .net4.0 中 usernametoken 的替换
-
该错误表明您有一个可以通过 HTTPS 访问的服务,并且您正在尝试通过 HTTP 访问它。只需在地址中更改它
-
@rajesh web 服务不是作为 HTTPS 托管的
-
@Gauls:添加时间戳和密码作为密码摘要是什么意思?你想把它添加到哪里?
标签: asp.net wcf visual-studio-2010 asp.net-4.0