{"id":43316,"date":"2024-12-01T10:55:31","date_gmt":"2024-12-01T02:55:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/43316\/"},"modified":"2024-12-01T10:55:31","modified_gmt":"2024-12-01T02:55:31","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e7%bb%93%e6%9e%84%e4%bd%9c%e4%b8%ba%e5%8f%82%e6%95%b0%e4%bc%a0%e9%80%92%e7%bb%99-xml-rpc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/43316\/","title":{"rendered":"\u5982\u4f55\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 xml-rpc"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span>  <span>&gt;<\/span> <span>\u5982\u4f55\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 xml-rpc<\/span><\/p>\n<h1>\u5982\u4f55\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 xml-rpc<\/h1>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-05-02 09:03:32<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5077\u5077\u52aa\u529b\uff0c\u6084\u65e0\u58f0\u606f\u5730\u53d8\u5f3a\uff0c\u7136\u540e\u60ca\u8273\u6240\u6709\u4eba\uff01\u54c8\u54c8\uff0c\u5c0f\u4f19\u4f34\u4eec\u53c8\u6765\u5b66\u4e60\u5566~\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 xml-rpc\u300b<\/span>\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u4e0d\u77e5\u9053\u5927\u5bb6\u5bf9\u5176\u90fd\u6709\u591a\u5c11\u4e86\u89e3\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u770b\u4e00\u5427\uff01\u5f53\u7136\uff0c\u975e\u5e38\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u8bc4\u8bba\uff0c\u7ed9\u51fa\u5408\u7406\u7684\u5efa\u8bae\uff0c\u6211\u4eec\u4e00\u8d77\u5b66\u4e60\uff0c\u4e00\u8d77\u8fdb\u6b65\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u5bf9 go \u6709\u70b9\u964c\u751f\uff0c\u4e00\u76f4\u5728\u5c1d\u8bd5\u4f7f\u7528 go api \u4e2d\u7684 xml-rpc \u65b9\u6cd5\uff0c\u4e3a\u6b64\u6211\u9009\u62e9\u4e86 https:\/\/github.com\/mattn\/go-xmlrpc \u5e76\u4e14\u4e00\u5207\u6b63\u5e38\uff0c\u76f4\u5230\u6211\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u3002\u5728\u6211\u5f97\u5230\u7684\u793a\u4f8b\u4e2d\uff0c\u7ed3\u6784\u662f python \u5b57\u5178\uff0c\u683c\u5f0f\u4e3a {string : string} \u6216\u7a7a\u5b57\u5178\u3002\u5982\u679c\u6211\u7ed9\u7ed3\u6784\u63d0\u4f9b\u6211\u5728 python \u793a\u4f8b\u4e2d\u4f7f\u7528\u7684\u503c\uff0c\u6211\u4f1a\u5f97\u5230\u6050\u614c\u670d\u52a1\u3002<\/p>\n<p>\u6211\u5c1d\u8bd5\u521b\u5efa\u6620\u5c04\u6216\u7a7a\u7ed3\u6784\uff0c\u4f46\u5b83\u4f1a\u8bf4\u7ed9\u5b9a\u7684\u53c2\u6570\u662f\u9519\u8bef\u7684\uff08\u9519\u8bef\u662f\u7531 xml-rpc \u5f15\u8d77\u7684\uff09\u3002\u5982\u679c\u6211\u5c1d\u8bd5\u5c06\u5176\u8f6c\u6362\u4e3a json \u5e76\u4f7f\u7528\u7f16\u7801\/json \u89e3\u7801\u5668\u89e3\u6790\u5b83\uff0c\u5b83\u4f1a\u8bf4\u6211\u4f7f\u7528\u4e86\u9519\u8bef\u7684\u7ed3\u6784\u3002<\/p>\n<pre>type data struct {\n serial_number   string\n production_date string\n}\n\nfunc myfunc(){\n data := data{serial_number: \"mb1034rk7856\", production_date: \"\"}\n equipmentid, er2 := xmlrpc.call(url,\"addequipment\",19,\n \"testid\", \"mac\",\"10.21.16.160\", 0, data, 0)\n\n if er2 != nil {\n  log.fatal(er2)\n }\n}<\/pre>\n<p>\u6211\u73b0\u5728\u5f97\u5230\u7684\u201c\u7ed3\u679c\u201d\uff1a<\/p>\n<pre>2019\/03\/26 15:31:20 http: panic serving [::1]:14885: reflect.Value.Interface: cannot return value obtained from unexported field or method\ngoroutine 66 [running]:\nnet\/http.(*conn).serve.func1(0xc00025a000)\n        C:\/Go\/src\/net\/http\/server.go:1746 +0xd7\npanic(0x8a6d00, 0x9efd20)\n        C:\/Go\/src\/runtime\/panic.go:513 +0x1c7\nreflect.valueInterface(0x8a6d00, 0xc001008060, 0xb8, 0x1, 0xc0010061b0, 0x2a)\n        C:\/Go\/src\/reflect\/value.go:989 +0x1c5\nreflect.Value.Interface(0x8a6d00, 0xc001008060, 0xb8, 0xc000239428, 0x1)\n        C:\/Go\/src\/reflect\/value.go:978 +0x4b\ngithub.com\/mattn\/go-xmlrpc.toXml(0x8f1740, 0xc001008060, 0x1, 0xe, 0x0)\n        C:\/Users\/oplin\/go\/src\/github.com\/mattn\/go-xmlrpc\/xmlrpc.go:282     +0x100d\ngithub.com\/mattn\/go-xmlrpc.makeRequest(0x95f701, 0xc, 0xc000239950, 0x7, 0x7, 0xc00016c380)\n        C:\/Users\/oplin\/go\/src\/github.com\/mattn\/go-xmlrpc\/xmlrpc.go:314 +0x1b0\ngithub.com\/mattn\/go-xmlrpc.call(0xd23a00, 0x9761ca, 0x3e, 0x95f701, 0xc, 0xc00021f950, 0x7, 0x7, 0x0, 0x0, ...)\n        C:\/Users\/oplin\/go\/src\/github.com\/mattn\/go-xmlrpc\/xmlrpc.go:322 +0x91\ngithub.com\/mattn\/go-xmlrpc.Call(0x9761ca, 0x3e, 0x95f701, 0xc, 0xc00021f950, 0x7, 0x7, 0x935ce0, 0xc00016c380, 0x0, ...)\n     C:\/Users\/oplin\/go\/src\/github.com\/mattn\/go-xmlrpc\/xmlrpc.go:368 +0x8d\nbitbucket.org\/epuzzle\/puzzle-backend\/web.IDontWantToLiveAnymore(0x1b682c0, 0xc0001f2010, 0xc00011a300)\n        C:\/Users\/oplin\/go\/src\/bitbucket.org\/epuzzle\/puzzle-backend \/web\/registration.go:208 +0x1a1\nnet\/http.HandlerFunc.ServeHTTP(0x988fb0, 0x1b682c0, 0xc0001f2010, 0xc00011a300)\n        C:\/Go\/src\/net\/http\/server.go:1964 +0x4b\ngithub.com\/gorilla\/mux.(*Router).ServeHTTP(0xc0001d0540, 0x1b682c0, 0xc0001f2010, 0xc00011a100)\n        C:\/Users\/oplin\/go\/src\/github.com\/gorilla\/mux\/mux.go:212 +0xd7\ngithub.com\/codegangsta\/negroni.Wrap.func1(0x1b682c0, 0xc0001f2010, 0xc00011a100, 0xc001008040)\n        C:\/Users\/oplin\/go\/src\/github.com\/codegangsta\/negroni\/negroni.go:46 +0x54\ngithub.com\/codegangsta\/negroni.HandlerFunc.ServeHTTP(0xc00028d340, 0x1b682c0, 0xc0001f2010, 0xc00011a100, 0xc001008040)\n        C:\/Users\/oplin\/go\/src\/github.com\/codegangsta\/negroni\/negroni.go:29 +0x55\ngithub.com\/codegangsta\/negroni.middleware.ServeHTTP(0x9f23a0, 0xc00028d340, 0xc00028d3a0, 0x1b682c0, 0xc0001f2010, 0xc00011a100)\n        C:\/Users\/oplin\/go\/src\/github.com\/codegangsta\/negroni\/negroni.go:38 +0xa3\ngithub.com\/codegangsta\/negroni.middleware.ServeHTTP-fm(0x1b682c0, 0xc0001f2010, 0xc00011a100)\n        C:\/Users\/oplin\/go\/src\/github.com\/codegangsta\/negroni\/negroni.go:38 +0x67\nbitbucket.org\/epuzzle\/puzzle-backend\/lib.Logger(0x1b682c0, 0xc0001f2010, 0xc00011a100, 0xc001008020)\n        C:\/Users\/oplin\/go\/src\/bitbucket.org\/epuzzle\/puzzle-backend \/lib\/middleware.go:13 +0x8f\ngithub.com\/codegangsta\/negroni.HandlerFunc.ServeHTTP(0x988f00, 0x1b682c0, 0xc0001f2010, 0xc00011a100, 0xc001008020)\n        C:\/Users\/oplin\/go\/src\/github.com\/codegangsta\/negroni\/negroni.go:29 +0x55\ngithub.com\/codegangsta\/negroni.middleware.ServeHTTP(0x9f23a0, 0x988f00, 0xc00028d380, 0x1b682c0, 0xc0001f2010, 0xc00011a100)\n        C:\/Users\/oplin\/go\/src\/github.com\/codegangsta\/negroni\/negroni.go:38 +0xa3\ngithub.com\/codegangsta\/negroni.(*Negroni).ServeHTTP(0xc0002c6690, 0x9f5540, 0xc0003142a0, 0xc00011a100)\n        C:\/Users\/oplin\/go\/src\/github.com\/codegangsta\/negroni\/negroni.go:98 +0xf5\nnet\/http.serverHandler.ServeHTTP(0xc0001c4750, 0x9f5540, 0xc0003142a0, 0xc00011a100)\n        C:\/Go\/src\/net\/http\/server.go:2741 +0xb2\nnet\/http.(*conn).serve(0xc00025a000, 0x9f5b80, 0xc0002dc300)\n        C:\/Go\/src\/net\/http\/server.go:1847 +0x64d\ncreated by net\/http.(*Server).Serve\n        C:\/Go\/src\/net\/http\/server.go:2851 +0x2fc<\/pre>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p>\u60a8\u7684\u6570\u636e\u4e2d\u7684\u5b57\u6bb5\u672a\u5bfc\u51fa\uff0c\u8fd9\u4f1a\u5bfc\u81f4\u5c1d\u8bd5\u4f7f\u7528\u53cd\u5c04\u5305\u8bbf\u95ee\u8be5\u503c\u65f6\u51fa\u73b0\u6050\u614c\u3002\u8fd9\u662f\u56e0\u4e3a xmlrpc \u5305\u5c1d\u8bd5\u8bbf\u95ee\u8fd9\u4e9b\u672a\u5bfc\u51fa\u5c5e\u6027\u7684\u503c\u3002 <\/p>\n<p>\u66f4\u6539\u60a8\u7684 <code>data<\/code>struct \u4ee5\u5bfc\u51fa\u5176\u5c5e\u6027\uff1a<\/p>\n<pre>type Data struct {\n  SerialNumber   string\n  ProductionDate string\n}\n<\/pre>\n<p>\u5728 go \u4e2d\uff0c\u5f53\u7c7b\u578b\u3001\u53d8\u91cf\u3001\u7ed3\u6784\u4f53\u5b57\u6bb5\u3001\u51fd\u6570\u6216\u65b9\u6cd5\u4ee5\u5c0f\u5199\u5b57\u6bcd\u5f00\u5934\u65f6\uff0c\u5b83\u88ab\u8ba4\u4e3a\u672a\u66b4\u9732\u7ed9\u5176\u4ed6\u5305\u3002\u8981\u516c\u5f00\u5b83\uff0c\u60a8\u9700\u8981\u4ee5\u5927\u5199\u5b57\u6bcd\u5f00\u5934\u4ed6\u4eec\u7684\u540d\u5b57\u3002\u53e6\u5916\uff0cgo \u4e2d\u7684\u547d\u540d\u7ea6\u5b9a\u662f camelcase\u3002 <\/p>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u5982\u4f55\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 xml-rpc\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &gt; &gt; \u5982\u4f55\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 xml-rpc \u5982\u4f55\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 xml-rpc \u6765\u6e90\uff1astackoverflow 2024-05-02 09:03:32 0\u6d4f\u89c8 \u6536\u85cf \u5077\u5077\u52aa\u529b\uff0c\u6084\u65e0\u58f0\u606f\u5730\u53d8\u5f3a\uff0c\u7136\u540e\u60ca\u8273\u6240\u6709\u4eba\uff01\u54c8\u54c8\uff0c\u5c0f\u4f19\u4f34\u4eec\u53c8\u6765\u5b66\u4e60\u5566~\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u300a\u5982\u4f55\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 xml-rpc\u300b\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u4e0d\u77e5\u9053\u5927\u5bb6\u5bf9\u5176\u90fd\u6709\u591a\u5c11\u4e86\u89e3\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u770b\u4e00\u5427\uff01\u5f53\u7136\uff0c\u975e\u5e38\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u8bc4\u8bba\uff0c\u7ed9\u51fa\u5408\u7406\u7684\u5efa\u8bae\uff0c\u6211\u4eec\u4e00\u8d77\u5b66\u4e60\uff0c\u4e00\u8d77\u8fdb\u6b65\uff01 \u95ee\u9898\u5185\u5bb9 \u6211\u5bf9 go \u6709\u70b9\u964c\u751f\uff0c\u4e00\u76f4\u5728\u5c1d\u8bd5\u4f7f\u7528 go api \u4e2d\u7684 xml-rpc \u65b9\u6cd5\uff0c\u4e3a\u6b64\u6211\u9009\u62e9\u4e86 https:\/\/github.com\/mattn\/go-xmlrpc \u5e76\u4e14\u4e00\u5207\u6b63\u5e38\uff0c\u76f4\u5230\u6211\u5c06\u7ed3\u6784\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u3002\u5728\u6211\u5f97\u5230\u7684\u793a\u4f8b\u4e2d\uff0c\u7ed3\u6784\u662f python \u5b57\u5178\uff0c\u683c\u5f0f\u4e3a {string : string} \u6216\u7a7a\u5b57\u5178\u3002\u5982\u679c\u6211\u7ed9\u7ed3\u6784\u63d0\u4f9b\u6211\u5728 python \u793a\u4f8b\u4e2d\u4f7f\u7528\u7684\u503c\uff0c\u6211\u4f1a\u5f97\u5230\u6050\u614c\u670d\u52a1\u3002 \u6211\u5c1d\u8bd5\u521b\u5efa\u6620\u5c04\u6216\u7a7a\u7ed3\u6784\uff0c\u4f46\u5b83\u4f1a\u8bf4\u7ed9\u5b9a\u7684\u53c2\u6570\u662f\u9519\u8bef\u7684\uff08\u9519\u8bef\u662f\u7531 xml-rpc \u5f15\u8d77\u7684\uff09\u3002\u5982\u679c\u6211\u5c1d\u8bd5\u5c06\u5176\u8f6c\u6362\u4e3a json \u5e76\u4f7f\u7528\u7f16\u7801\/json \u89e3\u7801\u5668\u89e3\u6790\u5b83\uff0c\u5b83\u4f1a\u8bf4\u6211\u4f7f\u7528\u4e86\u9519\u8bef\u7684\u7ed3\u6784\u3002 type data struct { serial_number string production_date string } func myfunc(){ data := data{serial_number: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-43316","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/43316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=43316"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/43316\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=43316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=43316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=43316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}