{"id":575,"date":"2019-06-19T10:27:52","date_gmt":"2019-06-19T02:27:52","guid":{"rendered":"http:\/\/blog.yyhcw.com\/?p=575"},"modified":"2019-06-19T10:27:52","modified_gmt":"2019-06-19T02:27:52","slug":"envenvelope-xmlns%e6%a0%bc%e5%bc%8fxml%e6%96%87%e4%bb%b6php%e8%a7%a3%e6%9e%90soap-soap-%e6%8e%a5%e5%8f%a3%e8%8e%b7%e5%8f%96xml","status":"publish","type":"post","link":"http:\/\/blog.yyhcw.com\/post\/575.html","title":{"rendered":"env:Envelope xmlns\u683c\u5f0fXML\u6587\u4ef6PHP\u89e3\u6790soap-SOAP \u63a5\u53e3\u83b7\u53d6XML"},"content":{"rendered":"<!--wp-compress-html--><!--wp-compress-html no compression--><p>\u8fd9\u51e0\u5929\u5728\u5bf9\u63a5<a href=\"http:\/\/blog.yyhcw.com\/post\/573.html\">\u7535\u4fe1\u7269\u8054\u7f51DCP\u5168\u7403\u8fde\u63a5\u7ba1\u7406\u5e73\u53f0<\/a>\uff0c\u4e4b\u524d\u6587\u7ae0\u5df2\u7ecf\u8bf4\u4e86\uff0c\u5947\u8469\u7684API\u5c45\u7136\u6709\u4e24\u79cd\u5f62\u5f0f\uff1a<\/p>\n<ul>\n<li>SOAP\u7c7b\u63a5\u53e3\u8c03\u7528\u00a0 \u4ee5\u4e0bAPI\u91c7\u7528\u4e86SOAP\u534f\u8bae\uff1a<\/li>\n<\/ul>\n<ol>\n<li>\u5361\u67e5\u8be2\u4e0e\u7ba1\u7406\u7c7bAPI\uff1b<\/li>\n<li>\u4f7f\u7528\u91cf\u6570\u636e\u67e5\u8be2\u4e0b\u8f7d\u7c7bAPI\uff1b<\/li>\n<li>\u7b56\u7565\u7ba1\u63a7\u7c7bAPI\u4e2d\u7684\uff1a\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>\u8fbe\u91cf\u65ad\u7f51\u7ba1\u7406\u7c7b\uff1b<\/li>\n<li>\u89e6\u53d1\u5668\u7ba1\u7406\u4e0e\u544a\u8b66\u7c7b\uff1b<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>SOAP \u662f\u4e00\u9879\u57fa\u4e8e XML \u7684\u534f\u8bae\uff0c\u5176\u5141\u8bb8\u5728\u53bb\u4e2d\u5fc3\u5316\u7684\u5206\u5e03\u5f0f\u73af\u5883\u4e2d\u4ea4\u6362\u4fe1\u606f\u3002SOAP \u6d88\u606f\u662f\u5305\u542b\u4ee5\u4e0b\u5143\u7d20\u7684\u666e\u901a XML \u6587\u6863\uff1a<\/p>\n<ul>\n<li>Envelope\uff08\u5c01\u5957\uff09\uff1a\u4e00\u4e2a\u5fc5\u8981\u5143\u7d20\uff0c\u7528\u4e8e\u5c06 XML \u6587\u6863\u6807\u8bc6\u4e3a SOAP \u6d88\u606f\u3002<\/li>\n<li>Header\uff08\u6807\u9898\uff09\uff1a\u4e00\u4e2a\u5305\u542b\u6807\u9898\u4fe1\u606f\u7684\u53ef\u9009\u5143\u7d20\u3002<\/li>\n<li>Body\uff08\u6b63\u6587\uff09\uff1a\u4e00\u4e2a\u5305\u542b\u8c03\u7528\u548c\u54cd\u5e94\u4fe1\u606f\u7684\u5fc5\u8981\u5143\u7d20\u3002<\/li>\n<li>Fault\uff08\u9519\u8bef\uff09\uff1a\u4e00\u4e2a\u53ef\u9009\u5143\u7d20\uff0c\u5176\u63d0\u4f9b\u4e86\u4e0e\u5904\u7406\u6d88\u606f\u671f\u95f4\u53d1\u751f\u7684\u9519\u8bef\u6709\u5173\u7684\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p>\u4eca\u5929\u4e3b\u8981\u9488\u5bf9PHP\u89e3\u6790soap-SOAP\u63a5\u53e3XML\u6587\u4ef6\uff0cPHP\u4f7f\u7528\u5e73\u5e38\u7684\u65b9\u5f0f\u6839\u672c\u5c31\u65e0\u6cd5\u6b63\u5e38\u89e3\u6790\u6b64XML\uff0c\u53ea\u80fd\u5bf9\u63a5\u6536\u5230\u7684XML\u6587\u4ef6\u8fdb\u884c\u7f16\u8f91\u4ee5\u540e\u624d\u80fd\u6b63\u5e38\u89e3\u6790\uff01XML\u683c\u5f0f\u5982\u4e0b\uff08\u6b64XML\u5df2\u88ab\u6211\u5c06\u67d0\u4e9b\u4fe1\u606f\u4fee\u6539\uff09\uff1a<\/p>\n<pre class=\"lang:php decode:true\">&lt;env:Envelope\r\n    xmlns:env='http:\/\/schemas.xmlsoap.org\/soap\/envelope\/'&gt;\r\n    &lt;env:Header&gt;&lt;\/env:Header&gt;\r\n    &lt;env:Body&gt;\r\n        &lt;ns2:QuerySimResourceResponse\r\n            xmlns:ns2=\"http:\/\/api.dcp.ericsson.net\/SubscriptionManagement\"&gt;\r\n            &lt;SimResource&gt;\r\n                &lt;msisdn&gt;86106237&lt;\/msisdn&gt;\r\n                &lt;imsi&gt;46011106&lt;\/imsi&gt;\r\n                &lt;icc&gt;89860308325&lt;\/icc&gt;\r\n                &lt;pin1&gt;12\/pin1&gt;\r\n                &lt;pin2&gt;9085&lt;\/pin2&gt;\r\n                &lt;puk1&gt;9363&lt;\/puk1&gt;\r\n                &lt;puk2&gt;6983&lt;\/puk2&gt;\r\n                &lt;imei&gt;86803103&lt;\/imei&gt;\r\n                &lt;assignedImei&gt;&lt;\/assignedImei&gt;\r\n                &lt;customerNo&gt;5609&lt;\/customerNo&gt;\r\n                &lt;accessControlClass&gt;6&lt;\/accessControlClass&gt;\r\n                &lt;roamProfileName&gt;1&lt;\/roamProfileName&gt;\r\n                &lt;deviceTerminalType&gt;&lt;\/deviceTerminalType&gt;\r\n                &lt;simSubscriptionStatus&gt;Active&lt;\/simSubscriptionStatus&gt;\r\n                &lt;simCardDescription&gt;\u7269\u8054\u536110649\u53f7\u6bb5&lt;\/simCardDescription&gt;\r\n                &lt;simSpecification&gt;CT_10649_SD&lt;\/simSpecification&gt;\r\n                &lt;priceProfileName&gt;PP000101389&lt;\/priceProfileName&gt;\r\n                &lt;productOfferName&gt;1565000006230_SP_01&lt;\/productOfferName&gt;\r\n                &lt;pdpContextProfileName&gt;PDPCP for ctnet CSD&lt;\/pdpContextProfileName&gt;\r\n                &lt;tenantId&gt;1&lt;\/tenantId&gt;\r\n                &lt;userProfileId&gt;CSD610&lt;\/userProfileId&gt;\r\n                &lt;firstActivationDate&gt;2019-06-03T03:13:09.673Z&lt;\/firstActivationDate&gt;\r\n                &lt;gprs&gt;true&lt;\/gprs&gt;\r\n                &lt;lte&gt;true&lt;\/lte&gt;\r\n                &lt;smsMo&gt;false&lt;\/smsMo&gt;\r\n                &lt;smsMt&gt;false&lt;\/smsMt&gt;\r\n                &lt;csd&gt;false&lt;\/csd&gt;\r\n                &lt;voice&gt;false&lt;\/voice&gt;\r\n                &lt;clip&gt;false&lt;\/clip&gt;\r\n                &lt;consumerConnectivity&gt;false&lt;\/consumerConnectivity&gt;\r\n                &lt;apns&gt;\r\n                    &lt;apn&gt;\r\n                        &lt;name&gt;ctnet&lt;\/name&gt;\r\n                        &lt;description&gt;ctnet&lt;\/description&gt;\r\n                    &lt;\/apn&gt;\r\n                &lt;\/apns&gt;\r\n                &lt;installationDate&gt;2019-06-03T03:13:09.673Z&lt;\/installationDate&gt;\r\n                &lt;pbrExitDate&gt;2019-06-18T03:57:11Z&lt;\/pbrExitDate&gt;\r\n                &lt;lastSubscriptionDateChange&gt;2019-06-03T03:13:09.673Z&lt;\/lastSubscriptionDateChange&gt;\r\n                &lt;moveToPermitted&gt;true&lt;\/moveToPermitted&gt;\r\n                &lt;freezeDuration&gt;0&lt;\/freezeDuration&gt;\r\n                &lt;chargeCodeForPPMove&gt;false&lt;\/chargeCodeForPPMove&gt;\r\n                &lt;chargeCodeNonPPMove&gt;false&lt;\/chargeCodeNonPPMove&gt;\r\n                &lt;customerName&gt;\u5357\u4eac\u7269\u8054\u7f51\u79d1\u6280\u6709\u9650\u516c\u53f8&lt;\/customerName&gt;\r\n                &lt;subscriptionPackageDescription&gt;\u5357\u4eac\u7269\u8054\u7f51-01-\u975e\u5b9a\u5411\u9636\u68af\u8ba1\u8d39-PBR50M180\u5929&lt;\/subscriptionPackageDescription&gt;\r\n                &lt;operatorId&gt;54000001&lt;\/operatorId&gt;\r\n            &lt;\/SimResource&gt;\r\n        &lt;\/ns2:QuerySimResourceResponse&gt;\r\n    &lt;\/env:Body&gt;\r\n&lt;\/env:Envelope&gt;<\/pre>\n<p>\u9700\u8981\u89e3\u6790\u4e0a\u9762\u7684XML\u9700\u5148\u8fdb\u884c\u5b57\u7b26\u4e32\u64cd\u4f5c\u624d\u53ef\u7528\u6b63\u5e38php\u89e3\u6790XML\u624d\u53ef\u4ee5\uff0c\u4e0b\u9762\u76f4\u63a5\u8d34\u4e0a\u4ee3\u7801\uff1a<\/p>\n<pre class=\"lang:php decode:true \">\/\/ \u5c06\u5f62\u5982&lt;soapenv:Envelope \u66ff\u6362\u4e3a\uff1a&lt;soapenvEnvelope\r\n$xmlStringnew = preg_replace('|&lt;([\/\\w]+)(:)|m','&lt;$1',$xmlStr);\r\n\/\/\u5c06\u5f62\u5982\uff1a xsi:type \u66ff\u6362\u4e3axsitype\r\n$xmlString = preg_replace('|(\\w+)(:)(\\w+=\\\")|m','$1$3',$xmlStringnew);\r\nlibxml_disable_entity_loader(true);\r\n$array = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);\r\nvar_dump($array);<\/pre>\n<p>OK,\u5df2\u7ecf\u53ef\u4ee5\u6b63\u5e38\u89e3\u6790soap-SOAP\u63a5\u53e3\u63d0\u4f9b\u7684XML\u6587\u4ef6\u4e86\uff01<\/p>\n<p>\u4e2d\u95f4\u8fd8\u9047\u5230\u8fc7\u5404\u79cd\u5751\uff0c\u5148\u4e0d\u8bf4\u4e86\uff0c\u8981\u8d76\u6570\u636e\uff01<\/p>\n<!--wp-compress-html no compression--><!--wp-compress-html-->","protected":false},"excerpt":{"rendered":"\u8fd9\u51e0\u5929\u5728\u5bf9\u63a5\u7535\u4fe1\u7269\u8054\u7f51DCP\u5168\u7403\u8fde\u63a5\u7ba1\u7406\u5e73\u53f0\uff0c\u4e4b\u524d\u6587\u7ae0\u5df2\u7ecf\u8bf4\u4e86\uff0c\u5947\u8469\u7684API\u5c45\u7136\u6709\u4e24\u79cd\u5f62\u5f0f\uff1a SOAP\u7c7b\u63a5\u53e3\u8c03 \u00b7\u00b7\u00b7","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"views":2534,"_links":{"self":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts\/575"}],"collection":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/comments?post=575"}],"version-history":[{"count":0,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/posts\/575\/revisions"}],"wp:attachment":[{"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/media?parent=575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/categories?post=575"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.yyhcw.com\/api\/wp\/v2\/tags?post=575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}