WSDL to PHP with Basic Auth

后端 未结 7 651
青春惊慌失措
青春惊慌失措 2020-11-30 10:28

I need to build php classes from a WSDL that is behind basic auth.

It has tons of namespaces so it looks burdensome to do this by hand.

I have tried a few to

相关标签:
7条回答
  • 2020-11-30 10:54

    This is Simple example to authenticate webservice using soapClient

    $apiauth =array('UserName'=>'abcusername','Password'=>'xyzpassword','UserCode'=>'1991');
    $wsdl = 'http://sitename.com/service.asmx?WSDL';
    $header = new SoapHeader('http://tempuri.org/', 'AuthHeader', $apiauth);
    $soap = new SoapClient($wsdl); 
    $soap->__setSoapHeaders($header);       
    $data = $soap->methodname($header);        
    

    This code internally parse header as follow

    <soap:Header>
        <AuthHeader xmlns="http://tempuri.org/">
          <UserName>abcusername</UserName>
          <Password>xyzpassword</Password>
          <UserCode>1991</UserCode>
        </AuthHeader>
    </soap:Header>
    
    0 讨论(0)
提交回复
热议问题