錯誤[a:InvalidSecurity] An error occurred when verifying security for the message.
InvalidSecurity當我嘗試SOAP調用我的WCF用戶名和密碼
我嘗試調用我的服務是這樣的。
PHP
<?php
$soapURL = "https://localhost:8888/wcf/?wsdl" ;
$soapParameters = Array('userName' => "user23", 'password' => "pass123") ;
$soapClient = new SoapClient($soapURL, $soapParameters);
var_dump($soapClient->GetVersion());
?>
我得到了它這樣的故障出在這裏的PHP代碼或在我的WCF,我相信的app.config沒有驗證之前的工作。
這裏是我的的app.config
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service
behaviorConfiguration="MYDLL.Behavior"
name="MYDLL.WCFService">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="UsernameAndSSL"
name="basicHttpBinding"
contract="MYDLL.IService"/>
<endpoint
address="mex"
binding="mexHttpsBinding"
bindingConfiguration=""
name="MexBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="https://localhost:8734/wcf/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MYDLL.Behavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="MYDLL.CustomUserNameValidator, MYDLL"/>
<serviceCertificate findValue="localhost" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName"/>
</serviceCredentials>
<useRequestHeadersForMetadataAddress />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="UsernameAndSSL">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Basic"/>
<message clientCredentialType="UserName"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
和customusernamevalidator
public class CustomUserNameValidator : UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
Console.WriteLine("User validation succeeded (Username: {0}; Password: {1})", userName, password);
}
}
我沒有什麼得到的是如果故障是在我的PHP代碼或配置。 consolewrite不會運行,我只是得到invalidSecurity異常,所以它似乎知道我有一個它不能找到的customusernamevalidation?
謝謝對不起,如果我沒有提到它,然後我自己託管wcf,但我可以指定身份驗證嗎?我在我的soap調用中做了一些適應,並將安全性更改爲使用基本cridentialtype進行傳輸,然後得到此錯誤。 SoapFault [HTTP]在我的功能行中未經授權。 – Dendei 2013-02-25 08:56:07
,但我仍然不能讓我的驗證器執行 – Dendei 2013-02-25 08:56:52
現在它的工作現在與添加行並重命名我的PHP參數爲「登錄」和「密碼」不知道如何工作但可能沒有高大寫字母? –
Dendei
2013-02-26 10:06:48