Tag: xml

yeoman不能编辑由其他子生成器创build的XML文件

我试图在一个由另一个创build的子生成器中对XML文件进行更改。 我的主生成器执行提示并确定应使用哪个子生成器。 简单的看起来像这样: var MainGenerator = module.exports = yeoman.generators.Base.extend({ writing: function () { this.composeWith('design:setup', {}); if (this.option.get('someOption')) { this.composeWith('design:extend', {}); } } }); 设置生成器会添加一些在devise的每个变体中使用的文件。 例如一个项目config.xml var SetupGenerator = module.exports = yeoman.generators.Base.extend({ default: function () { // ^ default: makes sure the vsSetup is run before the writing action // of the other sub generators this.fs.copy( […]

node-soap是否可以在单个WSDL中处理具有不同名称空间的多个模式?

我正在使用node-soap与现有的SOAP API进行接口。 我遇到了多个模式和命名空间的问题,从我正在阅读的内容可能是一个已知的问题。 这里是设置,我用一个WSDL文件和两个模式进行交互: WSDL(为简洁起见删除了属性和元素): <wsdl:definitions xmlns:tns="[rm-nsurl]" targetNamespace="[rm-nsurl]" …> <!– schema1 –> <schema xmlns:tns="[cm-nsurl]" targetNamespace="[cm-nsurl]" …> <complexType abstract="true" name="Operation"> <sequence> <element maxOccurs="1" minOccurs="0" name="operator" type="tns:Operator">…</element> </sequence> </<complexType </schema> <!– schema2 –> <schema xmlns:cm="[cm-nsurl]" xmlns:tns="[rm-nsurl]" targetNamespace="[rm-nsurl]" …> <complexType name="UserListOperation"> <complexContent> <extension base="cm:Operation">…</extension> </complexContent> </complexType> </schema> … </wsdl:definitions> 重要的细节是两个模式将tns定义为不同的值。 当schema2中的一个types引用了schema1( cm:Operation )中的一个元素时,它使用了cm的显式名称空间(目前为止还不错),但是随后跳转到schema1中的引用types中,我们现在看到了tns名称空间和schema1 tns是cm 。 这会导致问题,因为node-soap对于tns使用单个整体值,在这种情况下恰好是rm并且在需要时不显式使用cm命名空间。 这里是我看到问题的一个例子: 请求对象传递给WSDL方法: […]

除了使用下划线键以外,如何使用xml2js访问XML元素文本?

我有一块XML看起来像这样: <errorMessage> <payload encoding="plain">The error message</payload> </errorMessage> 我使用xml2jsparsing器: var parser = new xml2js.Parser({ explicitCharKey: false, trim: true, explicitRoot: true, mergeAttrs: true }); parser.parseString(myString, function(err, result) { var payload = result.errorMessage.payload; // how do I access the error message text? var errorMessage = payload[0]['_']; }); 我需要访问payload内容元素中The error messagestring。 如果我在包含<payload>的节点上使用_键,则正确检索文本,但使用下划线魔术键看起来可疑。 这是推荐的方式吗? 有没有更清洁的方法?

Twilio – logging一个排队的电话

我正在使用NodeJS与Twilio一起编写语音演示。 使用<enqueue>动词 ,传入的呼叫被放置在队列中,如下所示: <?xml version="1.0" encoding="UTF-8"?> <Response> <Enqueue waitUrl="/wait.xml">support</Enqueue> </Response> 在wait.xml中,我暂停并等待第二个客户端从队列中接收呼叫: <?xml version="1.0" encoding="UTF-8" ?> <Response> <Say voice="alice">Connecting to representative</Say> <Pause length="100"/> <Leave/> </Response> 当第二个客户端启动时,它使用<Dial>来使呼叫出列: <?xml version="1.0" encoding="UTF-8"?> <Response> <Dial record="record-from-answer" action="./record" method="GET"> <Queue>support</Queue> </Dial> </Response> 除通话logging外,所有function都按预期工作。 调用<client>时使用相同的原则,工作正常。 我错过了什么?

nodejs – 在另一个js文件中打印未定义的调用函数

我在执行下面的代码时出现以下错误: Failed: path must be a string Stack: TypeError: path must be a string at TypeError (native) at Object.fs.readFile (fs.js:250:11) 正在运行的代码如下所示: this.getNodeValueFromXML = function(xmlPath,node){ var self = this; try { var file = path.join(__dirname, xmlPath) fs.readFile(file, function(err, data) { if(err){ logger.warnLogger(err,'Error while processing XML file!!'); } else{ parser.parseString(data, function (err, result) { if(err){ logger.warnLogger(err,'Not a […]

节点SOAP如何发送参数/参数与请求

我正在做一个服务的肥皂调用,但无法弄清楚如何正确格式化和发送参数/客户client.method ,我想使用的参数。 client.describe()给了我这个: { SysGestAgentApi: { SysGestAgentApiSoapPort: { EXECSQL: [Object] ….以及更多,但是这个EXECSQL是我想要使用的方法。 此方法将SQL查询作为唯一参数作为string。 我试过的是这样的: var soap = require('soap'); var url = 'http://ipaddress:port/sysgestagentapi/SysGestAgentApi.WSDL'; var args = 'SELECT * FROM _33NWEB'; soap.createClient(url, function(err, client) { client.SysGestAgentApi.SysGestAgentApiSoapPort.EXECSQL(args, function(err, result) { console.log(result.toJSON()); }); }); 它一直在回应一个错误的XML,这是这样的: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode> <faultstring>WSDLReader:None of […]

Node / Express.js – 使用HTTP-Post获取XML并将其转换为JSON

我的任务看起来很简单:服务器发布一个XML文件。 我把这个XML文件,并将其转换为JSON,并通过res.send()返回此。 我使用Express,express-bodyparser,xml2js库和express-json来使用Node.js。 (也试过express-xml-bodyparser) 我的代码应该是这样的: […] app.post('/postXML', function(req,res,next){ xml2jsParser.parseString(req.body, function(err, result){ if(!err){ res.send(result); }else{ console.log(err); } }); parser.reset(); }); […] 我的问题是:req.body看起来像这样{" /*XML-file*/ "} typeof返回[object]。 xml2jsparsing器不能用于此。 所以我的两个解决scheme看起来像这样: JSON.stringify()的东西,并删除前两个和最后两个字符,你很好去。 但显然JSON.stringify()将该对象解释为一个string,用反斜杠对每个引号进行转义,从而使其不能用于我的xmlparser。 .toString的身体或string(req.body),再次削减额外的字符。 我发现,你也不能这样做。 它再次逃避引语。 (使用bodyParser.text()似乎也没有工作) xml2js需要一个如下所示的string: var xml = "<outer><inner attributename = "content"></inner></outer>" 发布的XML文件具有正确的格式,并且是默认格式良好的。 我已经用xml2json手动testing它,它工作正常。 我得到的内容也是正确的forms。 为了进一步自动化,我只需要通过Http-post得到这个工作。

在nodejs的请求模块中发送大的xml

我有一个非常大的xml使用wsjs节点模块生成。 看起来像 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:diag="http://diagnostic.ws.fcrewards.test.com/" xmlns:ws="http://www.w3.org/2005/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><soapenv:Header><ws:Action>http://diagnostic.ws.fcrewards.test.com/doEcho</ws:Action><ws:To>https://ws.mastercard.com/mtf/MRS/DiagnosticService</ws:To><ws:MessageID>35b479f1-5a54-e9a4-5551-0f15507f54b8</ws:MessageID><ws:ReplyTo><ws:Address>http://www.w3.org/2005/08/addressing/role/anonymous</ws:Address></ws:ReplyTo><o:Security><u:Timestamp wsu:Id="_0" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><u:Created>2017-02-24T17:13:13Z</u:Created><u:Expires>2017-02-24T17:18:13Z</u:Expires></u:Timestamp><o:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" u:Id="sec_0">MIID1zCCAr+gAwIBAgIRAIVAIPeDa+CgeYorExNgwDQYJKoZIhvcNAQELBQAwgYUxCzAJBgNVBAYTAkJFMRwwGgYDVQQKExNNYXN0ZUNhcmQgV29ybGR3aWRlMSQwIgYDVQQLExtHbG9iYWwgSW5mb3JtYXRpb24gU2VjdXJpdHkxMjAwBgNVBAjdjdjjdjdjjdjjdQgUFJEIE1lc3NhZ2VzIFNpssssssssssssssssssssssssIxNjIxMzcwN1owZjEbMBkGA1UEAxMSbXRmLkNIUy5wYXlGb3J3jdjjdjdjdjjdjjndkwlklwlwlwww25pbmcgU1cxDjAMBgNVBAsTBUNIUyAxMQswCQYDVQQGEwJVUzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAM675qti1N/aMP+YsPe9UIaJasISYzIpEoysKhClmWfBTqJTrcw0UWnraSOGqdPvEpgcLdW2BwnZ+T2gmcLa/BY69hW+CYm0pR0px9MPNuP77YcJCS5d6ffuHvTlkVpBq2hWVhOck0X0uhu+m2I6G8Dshi8yiBJohs+jpuf63OxVtBTemFNM5pVDdB5z7sYhkrdcNzlSoPTKNcTFfZgnj0G6iwkb4XK1mSlXbQL8jYEPPZWDdxPFl1SrSnwUoyl3r84SZrV13JstZ4YrolAm8mmKB7pU+bJ46+zpeYDRDo/YH4cxSpkyPUuwB27PtLk1J/9FgBNLfY0XQnlk/b3Mm3MCAwEAAaNgMF4wHwYDVR0jBBgwFoAU66ASd4JT9FhYrwHp4f9kBT5H2aowDAYDVR0TBAUwAwIBADAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFJ1obzmA1M2PIL8GumtHSIdwUrZMMA0GCSqGSIb3DQEBCwUAA4IBAQASqfFjdTt74OHwmEJVlO3pYnnHcxvDU0v7+2xTTMpWSAKmfDGf5j71UDsa6E/ymclcz/mdbsHSvyYii8TsrYK8Nyq6o2nTAQ0mhRhSpip7kjv5eQ0PtJZhl0Je7W9b3GIS1M5IbNN7xusKNHaJSg7ZIf/gUwWuBOq1CxABE0xRGY5b5e6giglP2iJwgeOHukmeGiLck3HGqZjei+T/Fnvsyy7hQ6qzGTDZg6B6yd1ojMZddmjDV8QsQfUQWM0//rvORZup98VP7I9LmrDBQuu7cPPy0Vg8VRWZC9wrM82e6IHl1uMovU12PCth1vAcSyTjuorNn5NoQg8FIoLCdgLk</o:BinarySecurityToken><Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference URI="#_0"><Transforms><Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>qNgtbxFDtGr1QCRG4ZnGSzfWqQ+GZJkuQAHgTxcI4B8=</DigestValue></Reference></SignedInfo><SignatureValue>ZqHJTwD91tcddddddddd3uZkuChVE0BHEx55YF3kGNw1D55VbunmbNZkmxxkuBvyAMjns/DJ8/duThXhlAmyPLYhRgj4djz8smJbksago1Tb+DFT8RQ4tOVPD2TPSaC5wrwA9g9zCCpPDHHv5FmZ4TIxwkPjG37MBqOIgUF8cUkL9kXU0sIJrUQddddddddddddddddddddddddddddddddddddddddddddddddddddddwsRtcjKDksvWpMBj0oSysWi+8/ce2HnO4nOuhrvX66BDOAyPL+avL2+JNTlA==</SignatureValue><KeyInfo><o:SecurityTokenReference><o:Reference URI="#sec_0" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></o:SecurityTokenReference></KeyInfo></Signature></o:Security></soapenv:Header><soapenv:Body><diag:doEcho>Cieran</diag:doEcho></soapenv:Body></soapenv:Envelope> 当我发送这个请求使用node.js的请求模块 request.post({ url: ctx.url, body: ctx.request, headers: { "SOAPAction": ctx.action, "Content-Type": ctx.contentType, "ContentLength": Buffer.byteLength(ctx.request), "MIME-Version": "1.0", "Connection": "Keep-Alive", "AcceptEncoding": "gzip" }, encoding: null, rejectUnauthorized: true, agentOptions: ctx.agentOptions }, function(error, response, body) { ctx.response = body […]

NodeJS(HapiJS)parsingXML

我是新的parsing和XML和使用nodejs,我已经尝试node-soap , easysoap , strong-soap ,但我不能让这个图书馆工作 这是我的XML如果我打开浏览器的链接 <definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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/" xmlns:tns="urn:myserv" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:myserv"> <types> <xsd:schema targetNamespace="urn:myserv"> <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/"/> <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/"/> <xsd:complexType name="reqSearch"> <xsd:sequence> <xsd:element name="Username" type="xsd:string" minOccurs="1"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="respSearch">…</xsd:complexType> </xsd:schema> </types> <message name="SearchRequest"> <part name="param" type="tns:reqSearch"/> </message> <message name="SearchResponse"> <part name="return" type="tns:respSearch"/> </message> <portType name="searchPortType"> <operation name="Search"> <documentation>Search Service</documentation> […]

使用node-soap发送正确的soap请求

我正在面对一个非常恼人的问题发送肥皂请求。 如果我使用像SOAP-UI这样的工具,我可以轻松地在XML中构build适当的soap请求。 但是,如果我试图使用节点肥皂发送此肥皂请求我无法得到正确的xmlstring… 我不知道为什么,但node-soap插件将string“SoapIn”附加到方法名称(GetArrBoardWithDetail)。 看下面的代码片段: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://thalesgroup.com/RTTI/2017-02-02/ldb/" xmlns:tok="http://thalesgroup.com/RTTI/2013-11-28/Token/types" xmlns:ct2007="http://thalesgroup.com/RTTI/2007-10-10/ldb/commontypes" xmlns:ct2015="http://thalesgroup.com/RTTI/2015-11-27/ldb/commontypes" xmlns:ldbt2017="http://thalesgroup.com/RTTI/2017-02-02/ldb/types"> <soapenv:Header> <tok:AccessToken> <tok:TokenValue>asdf</tok:TokenValue> </tok:AccessToken> </soapenv:Header> <soapenv:Body> <tns:**GetArrBoardWithDetailsSoapIn**> <tns:numRows>50</tns:numRows> <tns:crs>ACY</tns:crs> <tns:filterCrs></tns:filterCrs> <tns:filterType>to</tns:filterType> <tns:timeOffset>0</tns:timeOffset> <tns:timeWindow>120</tns:timeWindow> </tns:**GetArrBoardWithDetailsSoapIn**> </soapenv:Body> </soapenv:Envelope> 外部工具SoapUI不会附加像“SoapIn”这样的string。 肥皂用户界面附加string“Request”(请参阅​​下面的代码片段)。 <?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://thalesgroup.com/RTTI/2017-02-02/ldb/" xmlns:tok="http://thalesgroup.com/RTTI/2013-11-28/Token/types" xmlns:ct2007="http://thalesgroup.com/RTTI/2007-10-10/ldb/commontypes" xmlns:ct2015="http://thalesgroup.com/RTTI/2015-11-27/ldb/commontypes" xmlns:ldbt2017="http://thalesgroup.com/RTTI/2017-02-02/ldb/types"> <soapenv:Header> <tok:AccessToken> <tok:TokenValue>asdf</tok:TokenValue> </tok:AccessToken> </soapenv:Header> <soapenv:Body> <tns:**GetArrBoardWithDetailsRequest**> <tns:numRows>50</tns:numRows> <tns:crs>ACY</tns:crs> <tns:filterCrs></tns:filterCrs> <tns:filterType>to</tns:filterType> <tns:timeOffset>0</tns:timeOffset> <tns:timeWindow>120</tns:timeWindow> […]