0

I want to send and receive data with PHP SOAP. But there are no .wsdl links I am trying to send it with .svc link, but it gives 'auth' error.

How do I write this with PHP soap?

 <system.serviceModel>
<bindings>
  <customBinding >
   <!--CDM Servis için Binding Ayarı -->
    <binding name="CustomClientEArsivServicesBinding">
      <textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"
        messageVersion="Soap11" />
      <httpsTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
        maxBufferSize="2147483647" />        
   </binding>
  </customBinding>
</bindings>
<client>
 <!--CDM Servis için Endpoint Ayarı -->
  <endpoint address="https://xxxxxxxxx/ ClientEArsivServicesPort.svc" binding="customBinding"
    bindingConfiguration="Custom ClientEArsivServicesPortBinding" contract="FITOEServices. ClientEArsivServicesPort"
    name="ClientEArsivServicesPort" />
</client>

HTTP BASİC AUTH

Code I Write but I am getting 'Unauthorized' error

<?php

header('Content-type: text/html; charset=utf-8');
 ini_set("soap.wsdl_cache_enabled", "0");


class JaxWsSoapClient extends SoapClient
{
    public function __call($method, $arguments){
        $response = parent::__call($method, $arguments);
        return $response->return;
    }
}


 try { 
  
  $client       = new JaxWsSoapClient("http://xxxxxx.com/EArchiveInvoiceService.wsdl",
                                       array("trace" => 1,
                                             "location" =>"https:/xxxxxx.fitbulut.com/ClientEArsivServicesPort.svc",
                                             "uri" =>"http://xxxxxx/namespace/",
                                             "username" => "xxxxxxx",
                                             "password" => "G#xxxxx"          
                                     ));
 $result = $client->getInvoiceDocument('xxxx');

  echo"<br/>Dumping request headers:<br/>".$client->__getLastRequestHeaders();
  echo("<br/>Dumping request:<br/>".$client->__getLastRequest());
  echo("<br/>Dumping response headers:<br/>".$client->__getLastResponseHeaders());
  echo("<br/>Dumping response:<br/>".$client->__getLastResponse());
  echo("<br/>Returning value of __soapCall() call: ");
  var_dump($result->resultDataMap);

}catch(SoapFault $exception)
{
  print_r("Got issue:<br/>") ;
  echo '<pre>';
  print_r($exception);
  echo '</pre>';
}
?>

1 Answers1

0

BASİC AUTH .net CODE

ClientEArsivServicesPortClient wsClient = new ClientEArsivServicesPortClient ();
using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)wsClient.InnerChannel))
{
 string authorization = "UserName:Password";
 byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(authorization);
 string base64authorization = Convert.ToBase64String(byteArray); 
 System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, String.Format("Basic {0}", base64authorization));                
wsClient.getUserList (new getUserListRequest()); //call the service method
}