我正在开发WCF项目。当自定义(用户名)身份验证关闭时,从PHP调用WCF服务工作正常,但是当我打开身份验证时,我似乎无法访问WCF服务。但我可以通过自定义身份验证从.NET项目访问WCF服务。它只是PHP。我正在使用SSL。 下面是我在web.config中的绑定设置
<basicHttpBinding>
<binding name="MypBinding" allowCookies="true">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ApiService.UAuth, ApiService"/>
</serviceCredentials>
以下是我的示例php代码:
<?php
header('Content-Type: text/plain');
echo "start -> ";
echo " set wsdl var11111 -> ";
$soapclient = new SoapClient('https://api.address.com/Apii.svc?wsdl', array('login' => "username",'password' => "pwd",'default_socket_timeout' => 120, 'trace' => true));
echo " created soapclient ->";
echo $soapclient->GetData()->GetDataResult;
echo " end ";
print ' caught exception:'. $e->getMessage(). "\n";
return;
?>
任何建议都将不胜感激!