使用PHP的HTTPS上的WCF抛出“不允许的方法".例外 [英] WCF over HTTPS with PHP throws "Method Not Allowed" exception

查看:51
本文介绍了使用PHP的HTTPS上的WCF抛出“不允许的方法".例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个旨在始终通过HTTPS进行的.NET WCF服务.当我第一次创建服务框架并通过HTTP运行它时,它运行良好.我使用PHP5来测试与内置SOAP函数的互操作性.但是,一旦切换到HTTPS,当我尝试从PHP调用该函数时,会出现错误消息,提示方法不允许"和错误代码"http".它确实允许我检索方法列表.当它调用方法"Test"时发生错误.

I've created a .NET WCF service that is intended to always be over HTTPS. When I first created the service skeleton and ran it over HTTP, it worked fine. I used PHP5 to test the interoperability with the built in SOAP functions. However, once I switched to HTTPS, when I try to call the function from PHP, I get a fault back with the message "Method Not Allowed" and the fault code of "http." It does allow me to retrieve the list of methods though. The error occurs when it calls the method "Test."

这是WCF配置:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="secureBasic">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="apiBehavior" name="TestAPI.API">
        <endpoint address="https://192.168.0.3/API" 
                  binding="basicHttpBinding" 
                  bindingConfiguration="secureBasic" 
                  contract="TestAPI.IAPI"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="apiBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

这是PHP调用它的方式:

And here is how PHP is calling it:

$client = new SoapClient("https://192.168.0.3/API.svc?wsdl");
echo "<pre>" . print_r($client->__getFunctions(), 1) . "</pre>";
$param = new stdClass();
$param->A = "123";
$param->B = "456";
try {
    $client->Test($param);
} catch (Exception $e) {
    die("<pre>" . print_r($e,1) . "</pre>");
}

我正在使用自签名SSL证书进行测试,并且我认为PHP不需要受信任的证书.

I'm using a self-signed SSL certificate for testing and I don't believe PHP requires a trusted certificate.

我在做什么错了?

推荐答案

您是否尝试过网络嗅探器以查看实际从何处请求了什么?诸如Fiddler或Wireshark之​​类的东西(取决于情况).

Have you tried a network sniffer to see what actually got requested from where? Something like Fiddler or Wireshark (depending on the scenario).

也-我注意到您在< service ... 元素上缺少 behaviorConfiguration ="apiBehavior" .

Also - I note that you are missing behaviorConfiguration="apiBehavior" on the <service... element.

这篇关于使用PHP的HTTPS上的WCF抛出“不允许的方法".例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆