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 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划