Debugging PHP SOAP call

前端 未结 2 1373
耶瑟儿~
耶瑟儿~ 2020-12-21 01:00

I am new to SOAP and dealing with a web service where it would seem no one has interfaced using PHP previously. They have no example code excepting C# but I do have that.

2条回答
  •  清酒与你
    2020-12-21 01:17

    for debug purpose you can use Fiddler web debuger. I found it quite useful. In these days I'm working on a project based on .net web services, and I have to consume them via PHP. This is a working (and very simple) piece of code. Hope this can help you. The purpose of this piece of code is to check a status on a specific record.

    This is the wsdl

    POST /b1synccontext.asmx HTTP/1.1
    Host: 00.00.00.0
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://tempuri.org/QueueEntryGetStatus"
    
    
    
      
        
          int
        
      
    
    HTTP/1.1 200 OK
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    
    
    
      
        
          int
        
      
    
    

    This is the php code

    $client = new SoapClient("http://YOURIP/yourservice.asmx?wsdl",array(
                            'exceptions'=>true,
                            'cache_wsdl'=>WSDL_CACHE_NONE,
                            'encoding'=>'utf-8'));
    $params = array(
        'BuffID' => 134
        );
    
    try 
        {
            $result = $client->QueueEntryGetStatus($params);
            $status = $result->QueueEntryGetStatusResult;
            /*do something*/ 
        } 
        catch (Exception $e) 
        {
            $e -> getMessage();
            /*do something*/
        }
    

提交回复
热议问题