douyi4991 2011-09-21 14:58
浏览 84
已采纳

无法从php脚本调用WCF服务方法

I have WCF service. When I try to access it from .NET page all works fine. However I cannot find a way to access it from php script.

  <system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="NewBinding0">
      <reliableSession inactivityTimeout="01:00:00" />
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="Basic" />
        <message clientCredentialType="UserName" />
      </security>

    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="RegisterBehavior">
      <serviceDebug includeExceptionDetailInFaults="true" />
      <serviceMetadata httpsGetEnabled="true" />
      <serviceThrottling maxConcurrentCalls="48" maxConcurrentSessions="5000"
        maxConcurrentInstances="5000" />
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom"
          customUserNamePasswordValidatorType="..."
          cacheLogonTokens="true" cachedLogonTokenLifetime="01:00:00" />
      </serviceCredentials>
    </behavior>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service behaviorConfiguration="RegisterBehavior" name="Riepas.WCFRiepas">
    <endpoint address="..."
      binding="wsHttpBinding" bindingConfiguration="NewBinding0" contract="...">

    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" name="mex"
      contract="IMetadataExchange">

    </endpoint>
  </service>
</services>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
 />

Tried connecting from php, but it just hang. :(

    $client = new SoapClient("wsdl", array(
                                           'login'    => "...",
                                            'password' => "...",
                                            'soap_version'   => SOAP_1_2));
                                            $functions = $client->__getFunctions ();
var_dump ($functions);

$parameters = array("ReqVal" => "nu?");
//$result = $client->__soapCall("GetStr", $parameters);
//$result = $client->GetStr($parameters);

Functions returns normaly.

  • 写回答

1条回答 默认 最新

  • dso0139 2011-09-26 15:59
    关注

    In order to use the php soapclient, you need to use basicHttpBinding, not wsHttpBinding.

    For a very simple complete working example, see my Echo Service, which includes a php client.

    This downside of this is that your service will not implement WS-Reliable Messaging or WS-Security. However, if you need those, there is an open source party module called the WSO2 Web Services Framework for PHP that supposedly handles wsHttpBinding.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真