I am trying to generate the following XML block in php to send it to SMG soap server. How can i do that?
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dom="http://schemas.symantec.com/jaxws/domainProvisioningService">
<soapenv:Header/>
<soapenv:Body>
<dom:AddDomains>
<dom:domains>
<domain name="domain1.com" local="true">
</domain>
<domain name="domain2.com" local="true">
</domain>
</dom:domains>
</dom:AddDomains>
</soapenv:Body>
</soapenv:Envelope>
So #1 I hate working with soap. That said I would recommend using SoapClient ( https://www.php.net/manual/en/book.soap.php ).
You start off by instantiating a client and you pass in the wsdl like so:
$client = new SoapClient("some.wsdl", array('trace' => 1));
Whoever created the soap service will tell you where the wsdl is.
Now you can do something like:
$result = $client->AddDomains(
array(
array('name'=>'domain1.com', 'local'=>'true'),
array('name'=>'domain2.com', 'local'=>'true')
)
);
But that might not work because the WSDL might require some specific wacky formatting or something. You need to check that the response isn't a soapfault
if (is_soap_fault($result)) {
echo "REQUEST:\n" . $SOAP->__getLastRequest() . "\n";
echo "SOAP Fault: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring}";
}
This should hopefully get you on the right track.
I executed the following php block and desired output created:
$xmldom = new DOMDocument();
$domainsAttr = $xmldom->createElement( "domains" );
$domainAttr = $xmldom->createElement( "domain" );
$domainAttr->setAttribute( "name", "test.com" );
$domainAttr->setAttribute( "local", "true" );
$domainsAttr->appendChild( $domainAttr );
$xmldom->appendChild( $domainsAttr );
Here is desired output:
<domains><domain name="test.com" local="true"/></domains>
i omitted remaining code to post here, but when i execute the code, I get the following error:
Cannot find dispatch method for {}domains
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.