Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i send soap headers #200

Open
monika-mni opened this issue Nov 11, 2021 · 2 comments
Open

How can i send soap headers #200

monika-mni opened this issue Nov 11, 2021 · 2 comments

Comments

@monika-mni
Copy link

monika-mni commented Nov 11, 2021

I am unable to pass following authentication credentials in soap headers.
<soap:Header> <UserSessionCredentials xmlns=""> <UserId>int</UserId> <clientId>string</clientId>string </UserSessionCredentials> </soap:Header> <soap:Body> <GetSaveTemplate xmlns=""> <templateName>string</templateName> </GetSaveTemplate> </soap:Body>

Also when i am trying to send headers in $service->header($namespace, $name, $data), its returning following error:
Server was unable to process request. ---> Object reference not set to an instance of an object.

Any kind of help would be really appreciated.

@monika-mni
Copy link
Author

Hello @notfalsedev and Team,

This library is really useful, but i am sort of stuck with this small part. Can you please help me here.

@m-sami-ullah
Copy link

<?xml version="1.0" encoding="utf-8"?> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> <soap12:Header> <ClientHeader xmlns="http://retailexpress.com.au/"> <ClientID>id</ClientID> <UserName>username</UserName> <Password>password</Password> </ClientHeader> </soap12:Header> <soap12:Body> <CustomerGetDetails xmlns="http://retailexpress.com.au/"> <CustomerId>1</CustomerId> </CustomerGetDetails> </soap12:Body> </soap12:Envelope>

`
serviceName : what ever you want to set
$wsdl='https://www.domain.com/service.asmx?WSDL';

$this->soapWrapper->add('serviceName', function ($service) use ($wsdl) {
$service
->trace(true)
->wsdl($wsdl)
->header('http://retailexpress.com.au/','ClientHeader',['ClientID' =>'id','UserName' => 'username', 'Password' => 'password'])

              ;
         dump($service);

    });

$this->soapWrapper->client('serviceName',function($client){
echo '

Functions

';
dump($client->getFunctions());
// echo'

call

';

    $response = $client->call('CustomerGetDetails',[]);
    dd($response);
});

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants