views:

688

answers:

1

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."

Here is the WCF configuration:

  <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>

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>");
}

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

What am I doing wrong?

A: 

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

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

Marc Gravell
I've looked at Fiddler, but being that it is all encrypted, it doesn't seem to help much unless I am missing something.And I apologize about the behaviorConfiguration attribute missing. I had it in there and removed it before copying/pasting in my pursuit of trying to figure out the issue.
Shane
Well, Fiddler can decode ssl. but only if the session starts in IE. Does it fail over http? It might be that the problem is reproducible without https (since I didn't see any TransportWithMessageCredential), in which case inspection is easy.
Marc Gravell