locked
How to use WCF service from PHPclient(SOAP) with HTTPS protocol RRS feed

  • Question

  • User-1666202131 posted

    Hi All,

    I did some WCF service with next web config.


    <system.serviceModel>
    		<bindings>
    			
    			<basicHttpBinding>
    				<binding name="legacy">					
    					<security mode="Transport" >
    						<transport  clientCredentialType="None"/>						
    					</security>
    				</binding>
    			</basicHttpBinding>
    
    		</bindings>
    
    		<behaviors>
    
    			<serviceBehaviors>
    				<behavior name="My.Services.WCFBehavior">					
    					<serviceMetadata httpsGetEnabled="true"/>					
    					<serviceDebug includeExceptionDetailInFaults="false"/>					
    				</behavior>
    			</serviceBehaviors>
    
    			<endpointBehaviors>
    				<behavior name="WebBehavior">
    					<webHttp />
    				</behavior>
    			</endpointBehaviors>
    
    		</behaviors>
    
    		<services>
    			<service behaviorConfiguration="My.Services.WCFBehavior"
    					 name="My.Services.WCFServiceWCFService">
    						
    				<endpoint address=""
    						binding="basicHttpBinding"						   
    						bindingConfiguration="legacy"
    						contract="My.Services.WCFService.ISingleSignOnWCFService" />
    				
    				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    			</service>
    
    			<service behaviorConfiguration="My.Services.WCFBehavior"
    					 name="My.Services.Security.ServicesSecurity">
    				
    				<endpoint address=""
    								binding="basicHttpBinding"								 
    								bindingConfiguration="legacy"
    								contract="My.Services.Security.IServiceSecurity" />
    				
    				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    			</service>
    
    		</services>
    		<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    	</system.serviceModel>


    For IIS 6 I added SSL certificate.

    And when I try use this service from browser I see WSDL by HTTPS  protocol.

    https://localhost/ServicesSecurity.svc?wsdl

    Also I have PHP and Apace server what using 82 port http://localhost:82/soap.php

    In soap.php  I wrote next 


    <?php
    // $orig_error_reporting = error_reporting();
    // error_reporting(0);
    
    $soap = new SoapClient("https://localhost/SingleSignOnWCFService.svc?wsdl",
       array('soap_version' => 'SOAP_1_2',
             'location'=>'https://localhost/SingleSignOnWCFService.svc'));
    
    //error_reporting($orig_error_reporting);
    
    $start = gettimeofday (TRUE);
    for ($i=1;$i<100;$i++)
    {
    print "1";
    $response = $soap->GetPassword(array('cv_user_email'=>"a305@email.com",'cv_user_password'=>"123456")) ;
    //$response = $soap->__getTypes();
    print $response->GetPasswordResult ;
    print "<br>";
    }
    print gettimeofday(TRUE) - $start;
    ?>


    But when I try use this http://localhost:82/soap.php url.

    I got error with soap:

    Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://localhost/SingleSignOnWCFService.svc?wsdl' : failed to load external entity "https://localhost/SingleSignOnWCFService.svc?wsdl" in C:\wamp\www\soap.php:7 Stack trace: #0 C:\wamp\www\soap.php(7): SoapClient->SoapClient('https://localho...', Array) #1 {main} thrown in C:\wamp\www\soap.php on line 7

    are someone know how to call WCF  service from PHP with soap correct by using HTTPS ?

    And one more thing without security by HTTP all working !

    Thanks.



    Wednesday, September 15, 2010 5:54 AM

Answers

  • User-1666202131 posted

    Problem with easy fix:

    SSL was disabled in php.ini :)

    Now all working good. I like WCF Cool 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 15, 2010 11:15 AM