C
C
ChernovGV2015-08-12 06:29:55
PHP
ChernovGV, 2015-08-12 06:29:55

What should I do if, when calling a SOAP method, the request does not pass authorization, although there is access to the WSDL?

Good afternoon!
Php SOAP client does not pass authorization when calling a method, although there is access to the WSDL.
The magic is:

ini_set("soap.wsdl_cache_enabled", "0");
       $client    = new SoapClient($location, array('trace' => $trace, 'login' => $login, 'password' => $pass, 'soap_version' => 'SOAP_1_1'); //пробовал не указывать soap_version, а так же задавать параметр '1.1'
       //Объект создался корректно, достучались до WSDL
      $funcs = $client->__getFunctions();
      //Список функций получаем корректно
        try {
            $request = $client->method_name(array('RegistryNumber' => $this->_RegistryNumber));
           // Ответ - "SoapFault: Not Allowed"
        } catch (SoapFault $exception) {
            $last_request = $client->__getLastRequest();
            $test = $client->__doRequest($last_request, '$location','method_name','1.1');
             //Корректный ответ в XML формате
        }

I also tried to feed the generated request through SoapUI, there were no problems either.
I also want to note that these problems began after the transition to new formats for working with the SOAP server. Now a tunnel is forwarded to it through sTunnel.
Tell me which way to dig?
Thank you.
PS
var_dumps before calling the method:
object(Zh_Model_SoapClient)[55]
  public '_login' => string 'ХХХХ' (length=4)
  public '_password' => string 'ХХХХ' (length=16)
  public 'trace' => int 1
  public '_soap_version' => int 1
  public 'sdl' => resource(123, Unknown)
  public '__default_headers' => 
    array (size=1)
      0 => 
        object(SoapHeader)[61]
          public 'namespace' => string 'ХХХХХ' (length=51)
          public 'name' => string 'RequestHeader' (length=13)
          public 'data' => 
            object(SoapVar)[60]
              ...
          public 'mustUnderstand' => boolean false

and after calling:
object(Zh_Model_SoapClient)[55]
  public '_login' => string 'ХХХХ' (length=4)
  public '_password' => string 'ХХХХ' (length=16)
  public 'trace' => int 1
  public '_soap_version' => int 1
  public 'sdl' => resource(123, Unknown)
  public '__default_headers' => 
    array (size=1)
      0 => 
        object(SoapHeader)[61]
          public 'namespace' => string 'ХХХХ' (length=51)
          public 'name' => string 'RequestHeader' (length=13)
          public 'data' => 
            object(SoapVar)[60]
              ...
          public 'mustUnderstand' => boolean false
  public '__last_request' => string 'ХХХХХ'... (length=652)
  public 'httpsocket' => resource(126, stream)
  public '_use_proxy' => int 0
  public 'httpurl' => resource(128, Unknown)
  public '__last_request_headers' => string 'POST /404/ HTTP/1.1
Host: ХХХХ
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.5.13
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:method_name"
Content-Length: 652
Authorization: Basic ХХХХХ

' (length=244)
  public '__last_response_headers' => string 'HTTP/1.1 405 Not Allowed
Server: nginx
Date: Wed, 12 Aug 2015 03:22:39 GMT
Content-Type: text/html
Content-Length: 166
Connection: keep-alive
' (length=148)
  public '__soap_fault' => 
    object(SoapFault)[56]
      protected 'message' => string 'Not Allowed' (length=11)
      private 'string' (Exception) => string '' (length=0)
      protected 'code' => int 0
      protected 'file' => string 'ХХХХ' (length=63)
      protected 'line' => int 83
      private 'trace' (Exception) => 
        array (size=10)
          0 => 
            array (size=4)
              ...
          9 => 
            array (size=6)
              ...
      private 'previous' (Exception) => null
      public 'faultstring' => string 'Not Allowed' (length=11)
      public 'faultcode' => string 'HTTP' (length=4)
      public 'xdebug_message' => string '<tr><th align='left' bgcolor='#f57900' colspan="5"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> SoapFault: Not Allowed in ХХХ</th></tr>
<tr><th align='left' bgcolor='#e9b96e' colspan='5'>Call Stack</th></tr>
<tr><th align='center' bgcolor='#eeeeec'>#</th><th align='left' bgcolor='#eeeeec'>Time</th><th align='left' bgcolor='#eeeeec'>Memory</th><th align='left' bgcolor='#eeeeec'>Function<'... (length=4255)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
ChernovGV, 2015-08-20
@ChernovGV

$client = new SoapClient($location, array('trace' => $trace, 'location'=>$location, 'login' => $login, 'password' => $pass));

При создании объекта, помимо указания $location в первом параметре конструктора, его еще надо было указывать в массиве опций.
p.s.
Судя по всему это кривизна сервера, но тех поддержка не смогла помочь

Алексей Ostin, 2015-08-12
@nitso

Попробуйте отладить запрос через любой GUI-клиент (например, SoapUI) и последить за заголовками.
P.S. странный запрос, никакого редиректа не просходит ли?
__last_request_headers => POST /404/ HTTP/1.1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question