错误[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