Flickr SOAP APIのリクエストを作成しようとしていますが、正しい形式を取得できません。送信したいXMLは次のとおりです。
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema"
>
<s:Body>
<x:FlickrRequest xmlns:x="urn:flickr">
<method>flickr.test.echo</method>
<name>value</name>
</x:FlickrRequest>
</s:Body>
</s:Envelope>
これが私のコードです:
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$opts = array('location' => 'http://api.flickr.com/services/soap/',
'uri' => 'urn:flickr',
'trace' => 1
);
$client = new SOAPClient(null, $opts);
?>
<?php
try {
$data = $client->__soapCall('flickr.test.echo', array('name'));
print_r($data);
} catch (SoapFault $exception) {
echo 'Exception Thrown: '.$exception->faultstring.'<br><br>';
print "<pre>\n";
print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
print "</pre>";
}
?>
応答は次のとおりです。
Exception Thrown:
Request :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:flickr" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:flickr.test.echo>
<param0 xsi:type="xsd:string">name</param0>
</ns1:flickr.test.echo>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Response:
<?xml version="1.0" encoding="utf-8" ?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Body>
<s:Fault>
<faultcode>flickr.error.0</faultcode>
<faultstring>Invalid SOAP envelope.</faultstring>
<faultactor>http://www.flickr.com/services/soap/</faultactor>
<details>Please see http://www.flickr.com/services/api/ for more details</details>
</s:Fault>
</s:Body>
</s:Envelope>
残念ながら、FlickrはWSDLファイルを提供していません。
ありがとう
<< **更新** >>近づいています。私は自分のコードを変更しました、そしてそれはそれが本来あるべき場所にほとんどあります:
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$opts = array('location' => 'http://api.flickr.com/services/soap/',
'uri' => 'http://api.flickr.com/services/soap/',
'trace' => 1
);
$client = new SOAPClient(null, $opts);
?>
<?php
try {
$data = $client->__soapCall("FlickrRequest",
array(new SoapParam('flickr.test.echo', 'method'), new SoapParam('value', 'name')),
array('soapaction' => 'http://api.flickr.com/services/soap/')
);
print_r($data);
} catch (SoapFault $exception) {
echo 'Exception Thrown: '.$exception->faultstring.'<br><br>';
print "<pre>\n";
print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
print "</pre>";
}
?>
現在送信されているものは次のとおりです。
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.flickr.com/services/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:FlickrRequest>
<method xsi:type="xsd:string">flickr.test.echo</method>
<name xsi:type="xsd:string">value</name>
</ns1:FlickrRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>