我是新來使用.net 4.0 VS2010。我需要使用java web服務併發送usernametoken自定義身份驗證來訪問服務,這是我很容易在VS2005中使用WSE2.0,在net 4.0中替換這個是什麼?.net4.0 web應用程序消耗java web服務需要Usernametoken身份驗證
我的客戶端是.net 4.0 Asp.net web應用程序(網站),服務是java webservice。
得益於與谷歌的叔叔檢查後
好了下面的網站是基於我做我的代碼一些變化,但仍然沒有太大的喜悅GUD起點
。繼承人的代碼
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'。 參數名:通過
我嘗試使用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>
「接收器要求的消化密碼未被滿足」 強大的文本這就是實際的錯誤
我如何在頭髮送密碼作爲PasswordDigest?
您能指出不工作的代碼嗎? (並給出不起作用的代碼) – Aristos 2012-02-03 15:15:36
我根本不知道在.net4.0中替換usernametoken – Gauls 2012-02-03 15:27:33
錯誤指出您有一個可以通過HTTPS訪問的服務,並且您試圖通過HTTP訪問它。只需更改地址 – Rajesh 2012-02-07 12:28:47