Closed etcware closed 2 years ago
you need to pass a custom message factory to the client factory.
someting like
use Http\Discovery\Psr17FactoryDiscovery;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\RequestInterface;
// get your factory , as example $factory = new ClientFactory($metadata, $serializer);
$baseMessageFactory = Psr17FactoryDiscovery::findRequestFactory();
$myMessageFactory = new MyMessageFactory($baseMessageFactory);
$factory->setMessageFactory($messageFactory);
class MyMessageFactory implements RequestFactoryInterface
{
private RequestFactoryInterface $parentFactory;
public function __construct(RequestFactoryInterface $parentFactory): RequestInterface
{
$this->parentFactory = $parentFactory;
}
public function createRequest(string $method, $uri): RequestInterface
{
$message = $this->parentFactory->createRequest($method, $uri);
$message = $message->withHeaders(...); // add here your auth headers as example
return $message;
}
}
Thanks, but I have an additional problem, I cannot generate the metadata because also to access to WSDL during metadata generation needs credentials...
I need to pass credentials to soap client, is there an example to do this?