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
Envelope is undefined in the output from your XSL, so the error message:
makes perfect sense. You need to put something on the transform to create an Envelope and a Body:
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.