Search the Community
Showing results for tags 'wcf'.
-
How can we consume the WCF SSL Service in PHP client ?
hemantwithu posted a topic in PHP Coding Help
Hello All, I have developed a WCF service with htttps enabled.I have tested in .NET environment by creating a .NET windows client and consumed the service.I want to consume the same service php.I am new to php.I have written the below code <?php class WsseAuthHeader extends SoapHeader { private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'; function __construct($user, $pass, $ns = null) { if ($ns) { $this->wss_ns = $ns; } $auth = new stdClass(); $auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns); $auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns); $username_token = new stdClass(); $username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns); $security_sv = new SoapVar( new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns), SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns); parent::__construct($this->wss_ns, 'Security', $security_sv, true); } } $my_cert_file=".../wamp/mycert.pem"; $options = array('soap_version' => SOAP_1_2, 'exceptions' => TRUE, 'trace' => TRUE, 'wdsl_local_copy' => TRUE, 'style' => SOAP_DOCUMENT, 'use' => SOAP_AUTHENTICATION_DIGEST, 'encoding' => SOAP_ENCODED, 'cache_wsdl' => WSDL_CACHE_NONE, 'local_cert' => $my_cert_file); $username = "TestUser"; $password = "second"; $wsse_header = new WsseAuthHeader($username, $password); $client = new SoapClient('https://192.168.0.120/TravelPlanService.svc?wsdl',$options); $client->__setSoapHeaders(array($wsse_header)); try { $phpresponse= $client->Authenticate(); // print $phpresponse->GetResult->Version; echo (bool)$phpresponse->AuthenticateResult; echo "</b><BR/><BR/>"; } catch(Exception $e) { echo "<h2>Exception Error!</h2></b>"; echo $e->getMessage(); } ?> I have created a self signed certificate through online. Please provide me the solution to consume the HTTPS service in PHP . -
Hello. My mission is to develop a client to a third party's webservice, which server machine and source codes I can't access or handle. All I have is the API specifications and the addresses. The program works fine on DevelopEnvironment without authentication, but at ProductionEnvironment it requires basic http authentication plus certificate, and then I can't even receive any answer. They said me that I could use a self-signed certificate, so I've created one in my Server ( CentOS Apache2+PHP5.3.3 ). The company sent me a functional DotNetServiceClient piece of code, which includes the app.config which follows bellow. I need some example of how to send this authentication and more the certificate in PHP SoapClient or CURL. Here is the C# application's app.config, with fake IP and certificate: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.net> <settings> <servicePointManager expect100Continue="false" /> </settings> </system.net> <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_ISyasAutoServices"> <security> <message clientCredentialType="UserName" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://200.200.200.200/Auto/WebServiceAuto/SyasAutoServices.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISyasAutoServices" contract="ServiceReference1.ISyasAutoServices" name="WSHttpBinding_ISyasAutoServices"> <identity> <certificate encodedValue="AwAAAAEAAAAUAAAAmqc2gWanBIqn7sbzoxWEw==" /> </identity> </endpoint> </client> <behaviors> <endpointBehaviors> <behavior> <clientCredentials> <serviceCertificate> <authentication certificateValidationMode="None" revocationMode="NoCheck"/> </serviceCertificate> </clientCredentials> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel> </configuration> And here is my current client code: /* PHP WebService Client */ $connectionParameters = array( 'login' => 'login' ,'password' => 'password' ,'trace' => TRUE ,'encoding' => 'UTF-8' ,'exceptions' => TRUE ,'cache_wsdl' => WSDL_CACHE_NONE ,'soap_version' => SOAP_1_2 ,'local_cert' => file_get_contents('/my/certificate/directory/selfsignedcertificate/thatwebservice.pem') ,'passphrase' => 'd3e343der434wds' ); $theClient = new SoapClient($serverWSDLURL, $connectionParameters); $r = $theClient->GetBasicWorkData(); The answer: No answer! Only timeOut. Any example or tip? Thank you very much.
-
- soapclient
- asp.net
-
(and 3 more)
Tagged with: