Hello community,
MockAServ is available now -
http://mockaserv.stschnell.de/.
It works seamlessly with SpiderBasic. Here an example with a web service.
Hint: SpiderBasic web server runs on port 9080 and MockAServ runs on port 9980 - eighth in the code to the port of the WSDL URL.
Code: Select all
; Begin-----------------------------------------------------------------
; Directives----------------------------------------------------------
EnableExplicit
; Constants-----------------------------------------------------------
Enumeration
#MainWin
#btnGetData
#XMLTree
#XML
EndEnumeration
; Variables-----------------------------------------------------------
Global url.s = "http://127.0.0.1:9980/tempconvert.html?WSDL"
; Sub FillTree--------------------------------------------------------
Procedure FillTree(CurrentNode.i, CurrentSublevel.i)
; Variables-------------------------------------------------------
Protected NodeName.s, ChildNode.i
If XMLNodeType(CurrentNode) = #PB_XML_Normal
ChildNode = ChildXMLNode(CurrentNode)
NodeName = GetXMLNodeName(CurrentNode)
If ChildNode <> 0
AddGadgetItem(#XMLTree, -1, NodeName, 0, CurrentSublevel)
Else
If Trim(GetXMLNodeText(CurrentNode)) <> ""
AddGadgetItem(#XMLTree, -1, NodeName + " = " +
GetXMLNodeText(CurrentNode), 0, CurrentSublevel)
Else
AddGadgetItem(#XMLTree, -1, NodeName, 0, CurrentSublevel)
EndIf
EndIf
While ChildNode <> 0
FillTree(ChildNode, CurrentSublevel + 1)
ChildNode = NextXMLNode(ChildNode)
Wend
EndIf
EndProcedure
; Sub btnGetData------------------------------------------------------
Procedure btnGetData()
; Variables-------------------------------------------------------
Protected answer.s, MainNode.i
!$.ajax({
! type: "POST",
! url: v_url,
! contentType: 'text/xml',
! dataType: 'xml',
! headers: {
! 'Accept': '*/*'
! },
! success: processSuccess,
! error: processError
!});
!function processSuccess(data, textStatus, jqXHR) {
! if (textStatus == "success") {
! spider.debug.Print(textStatus);
! v_answer = jqXHR.responseText;
If ParseXML(#XML, answer)
If XMLStatus(#XML) = #PB_XML_Success
MainNode = MainXMLNode(#XML)
If MainNode
ClearGadgetItems(#XMLTree)
FillTree(MainNode, 0)
EndIf
EndIf
EndIf
! }
!}
!function processError(jqXHR, textStatus, errorThrown) {
! spider.debug.Print(textStatus);
!}
EndProcedure
; Main----------------------------------------------------------------
If OpenWindow(#MainWin, 10, 10, 480, 640, "GetData")
ButtonGadget(#btnGetData, 10, 10, 250, 24, "GetData")
TreeGadget(#XMLTree, 10, 44, 460, 586)
BindGadgetEvent(#btnGetData, @btnGetData())
EndIf
; End-------------------------------------------------------------------
; IDE Options = SpiderBasic 1.20 (Windows - x86)
; Folding = -
; WindowTheme = blue
; CompileSourceDirectory
And also seamlessly with SAP UI5.
Code: Select all
<!doctype html>
<html>
<!-- Example from http://services.odata.org/V4/OData/OData.svc/ -->
<head>
<title>OData test</title>
<meta http-equiv="Content-Type" content="text/html" />
<meta charset="ISO-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<script type="text/javascript" src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.ui.commons, sap.ui.table"
data-sap-ui-theme="sap_bluecrystal">
</script>
<script type="text/javascript">
//-Begin----------------------------------------------------------------
//-function main------------------------------------------------------
function main() {
//-Variables------------------------------------------------------
var oModel, oTable;
oTable = new sap.ui.table.Table("tableId",{
visibleRowCount : 8,
editable : false,
width : "500px"
});
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text: "ID"}),
visible : true,
template : new sap.ui.commons.TextView({text: "{ID}"})
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text: "Rating"}),
visible : true,
template : new sap.ui.commons.TextView({text: "{Rating}"})
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({text:"Price"}),
visible : true,
template : new sap.ui.commons.TextView({text: "{Price}"})
}));
oModel = new sap.ui.model.odata.ODataModel("http://127.0.0.1:9981/OData.svc");
oTable.setModel(oModel);
oTable.bindRows("/Products");
oTable.placeAt("content");
}
//-End------------------------------------------------------------------
</script>
</head>
<body class="sapUiBody" role="application" onLoad="main()">
<div id="content" />
</body>
</html>
Enjoy it.
Cheers
Stefan