以下是肥皂信封和标题信息:
POST /tf6/services/xdsrepositoryb HTTP/1.1
Content-Type: multipart/related;
boundary=MIMEBoundaryurn_uuid_566EAD10FEBB55C5A61257193478449;
type="application/xop+xml"; start="
<0.urn:uuid:566EAD10FEBB55C5A61257193478450@apache.org>"; start-
info="application/soap+xml";
action="urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b"
--MIMEBoundaryurn_uuid_566EAD10FEBB55C5A61257193478449
Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:566EAD10FEBB55C5A61257193478450@apache.org>
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
xmlns:wsa="http://www.w3.org/2005/08/addressing">
<soapenv:Header>
<wsa:To>http://localhost:5000/tf6/services/xdsrepositoryb</wsa:To>
<wsa:MessageID soapenv:mustUnderstand="true">urn:uuid:566EAD10FEBB55C5A61257193478400</wsa:MessageID>
<wsa:Action>urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<xdsb:ProvideAndRegisterDocumentSetRequest xmlns:xdsb="urn:ihe:iti:xds-b:2007">
<lcm:SubmitObjectsRequest xmlns:lcm="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0">
<rim:RegistryObjectList xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">
<rim:ExtrinsicObject id="Document01" mimeType="text/plain"
objectType="urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1">
</lcm:SubmitObjectsRequest>
<xdsb:Document id="Document01">
<xop:Include href="cid:1.urn:uuid:566EAD10FEBB55C5A61257193478499@apache.org"
xmlns:xop="http://www.w3.org/2004/08/xop/include"/>
</xdsb:Document>
</xdsb:ProvideAndRegisterDocumentSetRequest>
</soapenv:Body>
</soapenv:Envelope>
--MIMEBoundaryurn_uuid_566EAD10FEBB55C5A61257193478449
Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-ID: <1.urn:uuid:566EAD10FEBB55C5A61257193478499@apache.org>
This is my document.
It is great!
--MIMEBoundaryurn_uuid_566EAD10FEBB55C5A61257193478449--
如何使用CURL编写PHP脚本来发送请求?
每当我尝试拨打该服务时,我都会收到HTTP-400错误,请提供建议。
感谢。
答案 0 :(得分:0)
这是我正在尝试的代码:
$body= $body = '<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
<s:Header>
<a:Action s:mustUnderstand="1">urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b</a:Action>
<a:From>
<a:Address>urn:oid:2.16.840.1.113883.3.1259.10.1003</a:Address>
</a:From>
<a:To>https://CDACert.hawaiihie.org:20000/repository</a:To>
</s:Header>
<s:Body>
<ProvideAndRegisterDocumentSetRequest xmlns="urn:ihe:iti:xds-b:2007" xmlns:xop="http://www.w3.org/2004/08/xop/include">
<lcm3:SubmitObjectsRequest xmlns:lcm3="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0" xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0">
<rim:RegistryObjectList>
<rim:ExtrinsicObject id="Document1" mimeType="text/xml" objectType="urn:uuid:7edca82f-054d-47f2-a032-9b2a5b5186c1">
</rim:Association>
</rim:RegistryObjectList>
</lcm3:SubmitObjectsRequest>
<Document id=\"Document1\">
<xop:Include href="cid:test_ID_123"
xmlns:xop="http://www.w3.org/2004/08/xop/include"/></Document>
</ProvideAndRegisterDocumentSetRequest>
</s:Body>
';
$text = 'dGhpcyBpcyBTaGl2J3MgZG9j';// base64 of content
$boundary = 'MIMEBoundaryurn_uuid_'.uniqid();
$postData = "--$boundary\n"
."Content-Type: application/xop+xml; charset=UTF-8; type=\"application/soap+xml\n"
."Content-Transfer-Encoding: binary\n"
."Content-length:".strlen($body)."\n"
."Content-ID:test_start\n"
.$body."\n\n"
."--$boundary\n"
."Content-Type: text/plain;\n"
."Content-Transfer-Encoding: binary\n"
."Content-length:".strlen($text)."\n"
."Content-ID:test_ID_123\n"
.$text."\n"
."--$boundary--";
$header1 = array (
"Content-Type: multipart/related; type=\"application/xop+xml\"; start=\"test_start\"; start-info=\"application/soap+xml\"; action=\"urn:ihe:iti:2007:ProvideAndRegisterDocumentSet-b\"",
"Content-length:".strlen($postData),
"Transfer-Encoding:chunked",
"User-Agent:" .$_SERVER ['HTTP_USER_AGENT'],
"Host:" .$_SERVER['HTTP_HOST']
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $soapUrl);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLINFO_, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, array($postData)); // the SOAP request
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch); // 400 HTTP error from curl_info