Node.js 如何从Nodejs读取SOAP附件

Node.js 如何从Nodejs读取SOAP附件,node.js,soap,mtom,Node.js,Soap,Mtom,我在JBoss服务器上用JAVA编写了一个web服务。MTOM功能被激活,用于传输大型附件文件 我正在尝试实现一个NodeJS模块,用于调用web服务和流式传输附件的内容,但它不起作用: -我正在使用ws.js模块 -我的web服务正在使用JAVA或SOAP UI 下面是我的示例test.js: var ws = require('ws.js') , Http = ws.Http , Mtom = ws.Mtom var request = '<?xml

我在JBoss服务器上用JAVA编写了一个web服务。MTOM功能被激活,用于传输大型附件文件

我正在尝试实现一个NodeJS模块,用于调用web服务和流式传输附件的内容,但它不起作用: -我正在使用ws.js模块 -我的web服务正在使用JAVA或SOAP UI

下面是我的示例test.js:

var ws = require('ws.js')
      , Http = ws.Http
      , Mtom = ws.Mtom

    var request =  '<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:getDocument xmlns:ns2="http://core.streaming/"><versionSeriesId>{8039A45E-0000-C4AE-9C0F-272E6F941A47}</versionSeriesId></ns2:getDocument></S:Body></S:Envelope>';


    var ctx =  { request: request
               , url: "http://myServer/GateWay/Streaming"
               , action: ""
               , contentType: "application/soap+xml"
               }


    var handlers =  [ 
                    new Mtom(),
                     new Http()
                    ]

 console.log("Send");

    ws.send(handlers, ctx, function(ctx) {
      console.log("Receiving...");

     //var file = ws.getAttachment(ctx, "response", "//*[local-name(.)='test']")
      //fs.writeFileSync("result.txt", file)
    })

    //getting error here
var ws=require('ws.js')
,Http=ws.Http
,Mtom=ws.Mtom
var请求=“{8039A45E-0000-C4AE-9C0F-272E6F941A47}”;
var ctx={request:request
,网址:“http://myServer/GateWay/Streaming"
,行动:“
,contentType:“应用程序/soap+xml”
}
变量处理程序=[
新的Mtom(),
新的Http()
]
控制台日志(“发送”);
发送(处理程序、ctx、函数(ctx){
控制台日志(“接收…”);
//var file=ws.getAttachment(ctx,“response”,“/*[本地名称(.)='test']))
//fs.writeFileSync(“result.txt”,文件)
})
//这里有错误
调用在SOAP UI中工作,这里是原始web服务输出的示例:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: multipart/related; type="application/xop+xml"; boundary="uuid:38fb61e1-ab97-46d3-8abb-e904652a2276"; start="<root.message@cxf.apache.org>"; start-info="text/xml"
Transfer-Encoding: chunked
Date: Mon, 16 Oct 2017 06:31:50 GMT

--uuid:38fb61e1-ab97-46d3-8abb-e904652a2276
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <root.message@cxf.apache.org>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"/><soap:Body><ns2:getDocument xmlns:ns2="http://core.streaming><return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:dataHandlerContentInfo"><retrievalName>test</retrievalName><contentType>application/pdf</contentType><contentLength>178720</contentLength><content><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:e07148cd-cc96-4162-bb19-2fb832900587-94@cxf.apache.org"/></content><pageCount>0</pageCount></return><return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:contentInfo"><retrievalName>test2.pdf</retrievalName><contentType>application/pdf</contentType><contentLength>77399</contentLength><content><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:e07148cd-cc96-4162-bb19-2fb832900587-95@cxf.apache.org"/></content><pageCount>0</pageCount></return><return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns2:dataHandlerContentInfo"><retrievalName>test</retrievalName><contentType>application/pdf</contentType><contentLength>178720</contentLength><content><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:e07148cd-cc96-4162-bb19-2fb832900587-96@cxf.apache.org"/></content><pageCount>0</pageCount></return></ns2:getDocument></soap:Body></soap:Envelope>
--uuid:38fb61e1-ab97-46d3-8abb-e904652a2276
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <e07148cd-cc96-4162-bb19-2fb832900587-94@cxf.apache.org>
Content-Disposition: attachment;name="test"

%PDF-1.4
%ÿÿÿÿ
1 0 obj
<< /Pages 2 0 R /Type /Catalog >>
endobj
2 0 obj
....
HTTP/1.1200正常
服务器:ApacheCoote/1.1
内容类型:多部分/相关;type=“应用程序/xop+xml”;边界=“uuid:38fb61e1-ab97-46d3-8abb-e904652a2276”;start=“”;start info=“text/xml”
传输编码:分块
日期:2017年10月16日星期一06:31:50 GMT
--uuid:38fb61e1-ab97-46d3-8abb-e904652a2276
内容类型:应用程序/xop+xml;字符集=UTF-8;type=“text/xml”
内容传输编码:二进制
内容ID:
看这里
D:\Workspaces\nodejs>node test.js

    Send
    ??Am?y???6!♠?'3TO5aHZ????X???|,?1????iyI?K?9??T?$?????H??W??↓??FY?A??1????(??l)I
u?@:Z???t$▼??+???`@?▲?Y|??R↔?^?6b is not match the current start tagName:sS?
end tag name:   ?J?♣?i?3?A?☺???Ct►♫:)\\?↕??V{po?♥g0↑??↕1??¶T?*w♀?
X→☺s?$?;????l§:??_☼??-?3's2's2's2's2???i3l?o?U????9??9????aa?♠?♫?q??????????????
h♀-`☺??-        [???W?▬?5a?Fl??6?-b{?♫`??↔?_?◄?◄??N?♥?[x??▲qG??p'p6?♀??3a7??↔\◄?
B?7?P???0??☺??? ?x ♦#♫?Pa►_???▼C∟☺☼ ?D?O?????!∟q♀?X↑d?☻q0↑q<♀A? ◄??B??;↑♠Q??C4?D
?# ?p↓? ♫q2?¶?G<↕↕♀??(↑??A©0∟?hHD<♠F↑.?X??      ?xHF?♠)?o ↔F"?Q?3?A?‼►_????8♂? ?
?`∟?\↑?8??dH7\?)??8▼2◄O%\ ‼♀?►&".?,?? q1?↑?A    LB\J?♀r◄?C▲??0?p▬WB is not match
 the current start tagName:m?
source code out of document root
Receiving...