2

我正在开发 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;
?>

任何建议将不胜感激!

4

0 回答 0