IBM Worklight HTTP Adapter SOAP响应:XSL转换失败 [英] IBM Worklight HTTP Adapter SOAP response: XSL transformation failed

查看:309
本文介绍了IBM Worklight HTTP Adapter SOAP响应:XSL转换失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了一个调用soap web服务的http适配器==>它工作正常。
但是当我添加一个xsl转换文件并运行适配器程序

 转换:{
type :'xslFile',
xslFile:'filtered.xsl'
}

和一个空的xsl文件

 < xsl:stylesheet version =1.0
xmlns:xsl =http: //www.w3.org/1999/XSL/Transform
xmlns:h =http://www.w3.org/1999/xhtml>
< xsl:output method =text/>

< xsl:template match =/>
< / xsl:template>



我有以下内容错误:

 Ecma错误:TypeError:无法读取属性\Body \来自undefined 

Web服务返回的xml正常(使用WireShark检查)。



以下是适配器代码:

  function getLiveSessionsCountFiltered(){
var request =
< ; soapenv:Envelope xmlns:xsi =http://www.w3.org/2001/XMLSchema-instancexmlns:xsd =http://www.w3.org/2001/XMLSchemaxmlns:soapenv =http ://schemas.xmlsoap.org/soap/envelope/xmlns:met =http://metricsdata.webservicesimpl.server.introscope.wily.com>
< soapenv:Header />
< soapenv:Body>
< met:getLiveMetricData soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/>
< agentRegex xsi:type =xsd:string> myHost \ | websphere \ | myAgent< / agentRegex>
< metricPrefix xsi:类型= XSD:字符串 > WebSpherePMI\ | servletSessionsModule:LiveCount< / metricPrefix>
< / met:getLiveMetricData>
< / soapenv:正文>
< / soapenv:Envelope> ;;

var input = {
method:'post',
returnedContentType:'xml',
path:'/ introscope-web-services / services / MetricsDataService' ,
标题:{'SOAPAction':},
正文:{
内容:request.toString(),
contentType:'text / xml; charset = utf-8'
},
转换:{
类型:'xslFile',
xslFile:'filtered.xsl'
}
} ;

var result = WL.Server.invokeHttp(input);
返回result.Envelope.Body;
}

我的SOAP网络服务返回的XML:

 < soapenv:Envelope xmlns:soapenv =http://schemas.xmlsoap.org/soap/envelope/xmlns:xsd =http:/ /www.w3.org/2001/XMLSchemaxmlns:xsi =http://www.w3.org/2001/XMLSchema-instance> 
< soapenv:Body>
< ns1:getLiveMetricDataResponse soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xmlns:ns1 =http://metricsdata.webservicesimpl.server.introscope.wily.com >
< getLiveMetricDataReturn soapenc:arrayType =ns2:TimeslicedResultSetMetricData [8]xsi:type =soapenc:Arrayxmlns:ns2 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http: //schemas.xmlsoap.org/soap/encoding/\">
< getLiveMetricDataReturn href =#id0/>
< getLiveMetricDataReturn href =#id1/>
< getLiveMetricDataReturn href =#id2/>
< getLiveMetricDataReturn href =#id3/>
< getLiveMetricDataReturn href =#id4/>
< getLiveMetricDataReturn href =#id5/>
< getLiveMetricDataReturn href =#id6/>
< getLiveMetricDataReturn href =#id7/>
< / getLiveMetricDataReturn>
< / ns1:getLiveMetricDataResponse>
< multiRef id =id6soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns3:TimeslicedResultSetMetricDataxmlns: soapenc =http://schemas.xmlsoap.org/soap/encoding/xmlns:ns3 =urn:ca.wily.introscope.webservices>
< metricData soapenc:arrayType =ns3:MetricData [1]xsi:type =soapenc:Array>
< metricData href =#id8/>
< / metricData>
< timesliceEndTime xsi:type =xsd:dateTime> 2013-10-11T08:25:45.000Z< / timesliceEndTime>
< timesliceStartTime xsi:type =xsd:dateTime> 2013-10-11T08:25:30.000Z< / timesliceStartTime>
< / multiRef>
< multiRef id =id7soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns4:TimeslicedResultSetMetricDataxmlns: ns4 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< metricData soapenc:arrayType =ns4:MetricData [1]xsi:type =soapenc:Array>
< metricData href =#id9/>
< / metricData>
< timesliceEndTime xsi:type =xsd:dateTime> 2013-10-11T08:26:00.000Z< / timesliceEndTime>
< timesliceStartTime xsi:type =xsd:dateTime> 2013-10-11T08:25:45.000Z< / timesliceStartTime>
< / multiRef>
< multiRef id =id0soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns5:TimeslicedResultSetMetricDataxmlns: ns5 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< metricData soapenc:arrayType =ns5:MetricData [1]xsi:type =soapenc:Array>
< metricData href =#id10/>
< / metricData>
< timesliceEndTime xsi:type =xsd:dateTime> 2013-10-11T08:24:15.000Z< / timesliceEndTime>
< timesliceStartTime xsi:type =xsd:dateTime> 2013-10-11T08:24:00.000Z< / timesliceStartTime>
< / multiRef>
< multiRef id =id1soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns6:TimeslicedResultSetMetricDataxmlns: ns6 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< metricData soapenc:arrayType =ns6:MetricData [1]xsi:type =soapenc:Array>
< metricData href =#id11/>
< / metricData>
< timesliceEndTime xsi:type =xsd:dateTime> 2013-10-11T08:24:30.000Z< / timesliceEndTime>
< timesliceStartTime xsi:type =xsd:dateTime> 2013-10-11T08:24:15.000Z< / timesliceStartTime>
< / multiRef>
< multiRef id =id2soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns7:TimeslicedResultSetMetricDataxmlns: ns7 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< metricData soapenc:arrayType =ns7:MetricData [1]xsi:type =soapenc:Array>
< metricData href =#id12/>
< / metricData>
< timesliceEndTime xsi:type =xsd:dateTime> 2013-10-11T08:24:45.000Z< / timesliceEndTime>
< timesliceStartTime xsi:type =xsd:dateTime> 2013-10-11T08:24:30.000Z< / timesliceStartTime>
< / multiRef>
< multiRef id =id4soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns8:TimeslicedResultSetMetricDataxmlns: ns8 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< metricData soapenc:arrayType =ns8:MetricData [1]xsi:type =soapenc:Array>
< metricData href =#id13/>
< / metricData>
< timesliceEndTime xsi:type =xsd:dateTime> 2013-10-11T08:25:15.000Z< / timesliceEndTime>
< timesliceStartTime xsi:type =xsd:dateTime> 2013-10-11T08:25:00.000Z< / timesliceStartTime>
< / multiRef>
< multiRef id =id5soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns9:TimeslicedResultSetMetricDataxmlns: ns9 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< metricData soapenc:arrayType =ns9:MetricData [1]xsi:type =soapenc:Array>
< metricData href =#id14/>
< / metricData>
< timesliceEndTime xsi:type =xsd:dateTime> 2013-10-11T08:25:30.000Z< / timesliceEndTime>
< timesliceStartTime xsi:type =xsd:dateTime> 2013-10-11T08:25:15.000Z< / timesliceStartTime>
< / multiRef>
< multiRef id =id3soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns10:TimeslicedResultSetMetricDataxmlns: ns10 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< metricData soapenc:arrayType =ns10:MetricData [1]xsi:type =soapenc:Array>
< metricData href =#id15/>
< / metricData>
< timesliceEndTime xsi:type =xsd:dateTime> 2013-10-11T08:25:00.000Z< / timesliceEndTime>
< timesliceStartTime xsi:type =xsd:dateTime> 2013-10-11T08:24:45.000Z< / timesliceStartTime>
< / multiRef>
< multiRef id =id11soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns11:MetricDataxmlns: ns11 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< agentName xsi:type =xsd:string> myHost | websphere | myAgent< / agentName>
< metricName xsi:type =xsd:string> WebSpherePMI | servletSessionsModule:LiveCount< / metricName>
< metricType xsi:type =xsd:int> 258< / metricType>
< metricValue xsi:type =xsd:string> 0< / metricValue>
< / multiRef>
< multiRef id =id12soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns12:MetricDataxmlns: ns12 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< agentName xsi:type =xsd:string> myHost | websphere | myAgent< / agentName>
< metricName xsi:type =xsd:string> WebSpherePMI | servletSessionsModule:LiveCount< / metricName>
< metricType xsi:type =xsd:int> 258< / metricType>
< metricValue xsi:type =xsd:string> 0< / metricValue>
< / multiRef>
< multiRef id =id14soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns13:MetricDataxmlns: ns13 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< agentName xsi:type =xsd:string> myHost | websphere | myAgent< / agentName>
< metricName xsi:type =xsd:string> WebSpherePMI | servletSessionsModule:LiveCount< / metricName>
< metricType xsi:type =xsd:int> 258< / metricType>
< metricValue xsi:type =xsd:string> 0< / metricValue>
< / multiRef>
< multiRef id =id13soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns14:MetricDataxmlns: ns14 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< agentName xsi:type =xsd:string> myHost | websphere | myAgent< / agentName>
< metricName xsi:type =xsd:string> WebSpherePMI | servletSessionsModule:LiveCount< / metricName>
< metricType xsi:type =xsd:int> 258< / metricType>
< metricValue xsi:type =xsd:string> 0< / metricValue>
< / multiRef>
< multiRef id =id10soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns15:MetricDataxmlns: ns15 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< agentName xsi:type =xsd:string> myHost | websphere | myAgent< / agentName>
< metricName xsi:type =xsd:string> WebSpherePMI | servletSessionsModule:LiveCount< / metricName>
< metricType xsi:type =xsd:int> 258< / metricType>
< metricValue xsi:type =xsd:string> 0< / metricValue>
< / multiRef>
< multiRef id =id15soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns16:MetricDataxmlns: ns16 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< agentName xsi:type =xsd:string> myHost | websphere | myAgent< / agentName>
< metricName xsi:type =xsd:string> WebSpherePMI | servletSessionsModule:LiveCount< / metricName>
< metricType xsi:type =xsd:int> 258< / metricType>
< metricValue xsi:type =xsd:string> 0< / metricValue>
< / multiRef>
< multiRef id =id8soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns17:MetricDataxmlns: ns17 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< agentName xsi:type =xsd:string> myHost | websphere | myAgent< / agentName>
< metricName xsi:type =xsd:string> WebSpherePMI | servletSessionsModule:LiveCount< / metricName>
< metricType xsi:type =xsd:int> 258< / metricType>
< metricValue xsi:type =xsd:string> 0< / metricValue>
< / multiRef>
< multiRef id =id9soapenc:root =0soapenv:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/xsi:type =ns18:MetricDataxmlns: ns18 =urn:ca.wily.introscope.webservicesxmlns:soapenc =http://schemas.xmlsoap.org/soap/encoding/>
< agentName xsi:type =xsd:string> myHost | websphere | myAgent< / agentName>
< metricName xsi:type =xsd:string> WebSpherePMI | servletSessionsModule:LiveCount< / metricName>
< metricType xsi:type =xsd:int> 258< / metricType>
< metricValue xsi:type =xsd:string> 0< / metricValue>
< / multiRef>


解决方案

适配器完全按照你的要求去做。在XSL转换中,您将从服务器中删除响应(不返回任何内容),然后您希望在转换后出现结果Envelope.Body

  return result.Envelope.Body; 

在XSL的输出中未定义Envelope,因此错误消息:

 Ecma错误:TypeError:无法读取属性\Body\来自undefined 

非常有意义。你需要在变换上放一些东西来创建一个信封和一个身体:

 < xsl:template match =/> 
{Envelope:{Body:{content:这是内容}}}
< / xsl:template>

或者你可以将Envelope / Body留在你的身边XSL并且只返回内容的JSON。



但是如果你在XSL中打开正文,你就不能在函数的return语句中再次执行它。 / p>

i've built an http adapter that call a soap web service ==> it works fine. But when i add a xsl transformation file and run the adapter procedure with

        transformation : {
            type : 'xslFile',
            xslFile : 'filtered.xsl'
        }

and an empty xsl file

<xsl:stylesheet version="1.0"
            xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
            xmlns:h="http://www.w3.org/1999/xhtml">
<xsl:output method="text"/>

<xsl:template match="/">
</xsl:template>

i've got the following error:

"Ecma Error: TypeError: Cannot read property \"Body\" from undefined

The xml returned by the web service is OK (checked with WireShark).

Here is the adapter code:

function getLiveSessionsCountFiltered() {
var request = 
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:met="http://metricsdata.webservicesimpl.server.introscope.wily.com">
   <soapenv:Header/>
   <soapenv:Body>
      <met:getLiveMetricData soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <agentRegex xsi:type="xsd:string">myHost\|websphere\|myAgent</agentRegex>
         <metricPrefix xsi:type="xsd:string">WebSpherePMI\|servletSessionsModule:LiveCount</metricPrefix>
      </met:getLiveMetricData>
   </soapenv:Body>
</soapenv:Envelope>;

var input = {
        method : 'post',
        returnedContentType : 'xml',
        path : '/introscope-web-services/services/MetricsDataService',
        headers: {'SOAPAction':""},
        body : {
            content: request.toString(),
            contentType: 'text/xml; charset=utf-8'
        },
        transformation : {
            type : 'xslFile',
            xslFile : 'filtered.xsl'
        }
    };

    var result = WL.Server.invokeHttp(input);
    return result.Envelope.Body;
}

And the XML returned by my SOAP webservice:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <ns1:getLiveMetricDataResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://metricsdata.webservicesimpl.server.introscope.wily.com">
         <getLiveMetricDataReturn soapenc:arrayType="ns2:TimeslicedResultSetMetricData[8]" xsi:type="soapenc:Array" xmlns:ns2="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
            <getLiveMetricDataReturn href="#id0"/>
            <getLiveMetricDataReturn href="#id1"/>
            <getLiveMetricDataReturn href="#id2"/>
            <getLiveMetricDataReturn href="#id3"/>
            <getLiveMetricDataReturn href="#id4"/>
            <getLiveMetricDataReturn href="#id5"/>
            <getLiveMetricDataReturn href="#id6"/>
            <getLiveMetricDataReturn href="#id7"/>
         </getLiveMetricDataReturn>
      </ns1:getLiveMetricDataResponse>
      <multiRef id="id6" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns3:TimeslicedResultSetMetricData" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns3="urn:ca.wily.introscope.webservices">
         <metricData soapenc:arrayType="ns3:MetricData[1]" xsi:type="soapenc:Array">
            <metricData href="#id8"/>
         </metricData>
         <timesliceEndTime xsi:type="xsd:dateTime">2013-10-11T08:25:45.000Z</timesliceEndTime>
         <timesliceStartTime xsi:type="xsd:dateTime">2013-10-11T08:25:30.000Z</timesliceStartTime>
      </multiRef>
      <multiRef id="id7" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:TimeslicedResultSetMetricData" xmlns:ns4="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <metricData soapenc:arrayType="ns4:MetricData[1]" xsi:type="soapenc:Array">
            <metricData href="#id9"/>
         </metricData>
         <timesliceEndTime xsi:type="xsd:dateTime">2013-10-11T08:26:00.000Z</timesliceEndTime>
         <timesliceStartTime xsi:type="xsd:dateTime">2013-10-11T08:25:45.000Z</timesliceStartTime>
      </multiRef>
      <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:TimeslicedResultSetMetricData" xmlns:ns5="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <metricData soapenc:arrayType="ns5:MetricData[1]" xsi:type="soapenc:Array">
            <metricData href="#id10"/>
         </metricData>
         <timesliceEndTime xsi:type="xsd:dateTime">2013-10-11T08:24:15.000Z</timesliceEndTime>
         <timesliceStartTime xsi:type="xsd:dateTime">2013-10-11T08:24:00.000Z</timesliceStartTime>
      </multiRef>
      <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns6:TimeslicedResultSetMetricData" xmlns:ns6="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <metricData soapenc:arrayType="ns6:MetricData[1]" xsi:type="soapenc:Array">
            <metricData href="#id11"/>
         </metricData>
         <timesliceEndTime xsi:type="xsd:dateTime">2013-10-11T08:24:30.000Z</timesliceEndTime>
         <timesliceStartTime xsi:type="xsd:dateTime">2013-10-11T08:24:15.000Z</timesliceStartTime>
      </multiRef>
      <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns7:TimeslicedResultSetMetricData" xmlns:ns7="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <metricData soapenc:arrayType="ns7:MetricData[1]" xsi:type="soapenc:Array">
            <metricData href="#id12"/>
         </metricData>
         <timesliceEndTime xsi:type="xsd:dateTime">2013-10-11T08:24:45.000Z</timesliceEndTime>
         <timesliceStartTime xsi:type="xsd:dateTime">2013-10-11T08:24:30.000Z</timesliceStartTime>
      </multiRef>
      <multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns8:TimeslicedResultSetMetricData" xmlns:ns8="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
         <metricData soapenc:arrayType="ns8:MetricData[1]" xsi:type="soapenc:Array">
            <metricData href="#id13"/>
         </metricData>
     <timesliceEndTime xsi:type="xsd:dateTime">2013-10-11T08:25:15.000Z</timesliceEndTime>
     <timesliceStartTime xsi:type="xsd:dateTime">2013-10-11T08:25:00.000Z</timesliceStartTime>
  </multiRef>
  <multiRef id="id5" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns9:TimeslicedResultSetMetricData" xmlns:ns9="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <metricData soapenc:arrayType="ns9:MetricData[1]" xsi:type="soapenc:Array">
        <metricData href="#id14"/>
     </metricData>
     <timesliceEndTime xsi:type="xsd:dateTime">2013-10-11T08:25:30.000Z</timesliceEndTime>
     <timesliceStartTime xsi:type="xsd:dateTime">2013-10-11T08:25:15.000Z</timesliceStartTime>
  </multiRef>
  <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns10:TimeslicedResultSetMetricData" xmlns:ns10="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <metricData soapenc:arrayType="ns10:MetricData[1]" xsi:type="soapenc:Array">
        <metricData href="#id15"/>
     </metricData>
     <timesliceEndTime xsi:type="xsd:dateTime">2013-10-11T08:25:00.000Z</timesliceEndTime>
     <timesliceStartTime xsi:type="xsd:dateTime">2013-10-11T08:24:45.000Z</timesliceStartTime>
  </multiRef>
  <multiRef id="id11" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns11:MetricData" xmlns:ns11="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <agentName xsi:type="xsd:string">myHost|websphere|myAgent</agentName>
     <metricName xsi:type="xsd:string">WebSpherePMI|servletSessionsModule:LiveCount</metricName>
     <metricType xsi:type="xsd:int">258</metricType>
     <metricValue xsi:type="xsd:string">0</metricValue>
  </multiRef>
  <multiRef id="id12" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns12:MetricData" xmlns:ns12="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <agentName xsi:type="xsd:string">myHost|websphere|myAgent</agentName>
     <metricName xsi:type="xsd:string">WebSpherePMI|servletSessionsModule:LiveCount</metricName>
     <metricType xsi:type="xsd:int">258</metricType>
     <metricValue xsi:type="xsd:string">0</metricValue>
  </multiRef>
  <multiRef id="id14" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns13:MetricData" xmlns:ns13="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <agentName xsi:type="xsd:string">myHost|websphere|myAgent</agentName>
     <metricName xsi:type="xsd:string">WebSpherePMI|servletSessionsModule:LiveCount</metricName>
     <metricType xsi:type="xsd:int">258</metricType>
     <metricValue xsi:type="xsd:string">0</metricValue>
  </multiRef>
  <multiRef id="id13" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns14:MetricData" xmlns:ns14="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <agentName xsi:type="xsd:string">myHost|websphere|myAgent</agentName>
     <metricName xsi:type="xsd:string">WebSpherePMI|servletSessionsModule:LiveCount</metricName>
     <metricType xsi:type="xsd:int">258</metricType>
     <metricValue xsi:type="xsd:string">0</metricValue>
  </multiRef>
  <multiRef id="id10" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns15:MetricData" xmlns:ns15="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <agentName xsi:type="xsd:string">myHost|websphere|myAgent</agentName>
     <metricName xsi:type="xsd:string">WebSpherePMI|servletSessionsModule:LiveCount</metricName>
     <metricType xsi:type="xsd:int">258</metricType>
     <metricValue xsi:type="xsd:string">0</metricValue>
  </multiRef>
  <multiRef id="id15" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns16:MetricData" xmlns:ns16="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <agentName xsi:type="xsd:string">myHost|websphere|myAgent</agentName>
     <metricName xsi:type="xsd:string">WebSpherePMI|servletSessionsModule:LiveCount</metricName>
     <metricType xsi:type="xsd:int">258</metricType>
     <metricValue xsi:type="xsd:string">0</metricValue>
  </multiRef>
  <multiRef id="id8" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns17:MetricData" xmlns:ns17="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <agentName xsi:type="xsd:string">myHost|websphere|myAgent</agentName>
     <metricName xsi:type="xsd:string">WebSpherePMI|servletSessionsModule:LiveCount</metricName>
     <metricType xsi:type="xsd:int">258</metricType>
     <metricValue xsi:type="xsd:string">0</metricValue>
  </multiRef>
  <multiRef id="id9" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns18:MetricData" xmlns:ns18="urn:ca.wily.introscope.webservices" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
     <agentName xsi:type="xsd:string">myHost|websphere|myAgent</agentName>
     <metricName xsi:type="xsd:string">WebSpherePMI|servletSessionsModule:LiveCount</metricName>
     <metricType xsi:type="xsd:int">258</metricType>
     <metricValue xsi:type="xsd:string">0</metricValue>
  </multiRef>

解决方案

The adapter is doing exactly what you tell it to do. In the XSL transform, you are dropping the response from the server (returning nothing), and then you are expecting the result Envelope.Body to be present after the transform

return result.Envelope.Body;

Envelope is undefined in the output from your XSL, so the error message:

"Ecma Error: TypeError: Cannot read property \"Body\" from undefined

makes perfect sense. You need to put something on the transform to create an Envelope and a Body:

<xsl:template match="/">
    {"Envelope": {"Body": {"content": "This is the content"}}}
</xsl:template>

Or you could just leave Envelope/Body out of your XSL and just return the JSON of content.

But if you unwrap the body in the XSL, you can't do it again in the return statement of your function.

这篇关于IBM Worklight HTTP Adapter SOAP响应:XSL转换失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆