WSDL to PHP with Basic Auth

后端 未结 7 712
青春惊慌失措
青春惊慌失措 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:31

    i’ve been trying to resolve this issue, but from what i understand, soap client connections to ssl+httpauth web services are more pain. I’ve googled and from what i understand, with my problem being solved, you can use the example below to solve your problem too(by using HttpAuth infos in both url and soapClient setup).

    $username="test";
    $password="test";
    $url = "https://".urlencode($username).":".urlencode($password)."@example.com/service.asmx?WSDL";
    
    $context = stream_context_create([
    'ssl' => [
    // set some SSL/TLS specific options
    'verify_peer' => false,
    'verify_peer_name' => false,
    'allow_self_signed' => true,
    ]]);
    
    $client = new SoapClient($url, [
    'location' => $url,
    'uri' => $url,
    'stream_context' => $context,
    'login' => $username,
    'password' => $password
    ]);
    
    $params=array(
    'operation'=>’arguments',
    'and’=>'other bull',
    'goes’=>'here'
    );
    
    $response = $client->__soapCall('OperationName', array($params)); 
    

提交回复
热议问题