I want to create xml format like function below, but when i run it in postman,
i got the below error
Exception: String could not be parsed as XML.
How to fix this?
This is my function :
public function testapi(Request $request){
$url = "http://xxx.xx.x.xx:xxxx/xxxx/Activity?wsdl";
$client = new \nusoap_client($url, 'wsdl');
$xmlstr = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:c1f="http://splwg.com/C1FieldActivityMaintenance.xsd">';
$xml = new \SimpleXMLElement($xmlstr);
$header = $xml->addChild('Header');
$security = $header->addChild('wsse:Security', '', 'wsse');
$userToken = $security->addChild('wsse:UsernameToken');
$userToken->addChild('wsse:Username', env('Username', ''));
$userToken->addChild('wsse:Password', env('Password', ''));
$client = new Client();
$response = $client->post($url, [
'headers' => [
'SOAPAction' => $action,
'Content-Type' => 'text/xml'
],
'body' => $xml
]);
return $response->getBody()->getContents();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire