开发者

Cannot call WCF service methods from php script

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 includeExceptionDetail开发者_JAVA技巧InFaults="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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜