RetroZilla/extensions/webservices/soap/tests/soapheadlinenews.html

88 lines
2.9 KiB
HTML
Raw Normal View History

2015-10-21 05:03:22 +02:00
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>SOAP Test: Headline News</H1>
This requests headline news from the selected domain and opens a window and
places the resulting HTML string into the window. Not all domains work all
the time. This service uses the low-level SOAP API of Mozilla directly, not
hiding the use of the API in separate proxy objects as other examples may do.
<p>View the source of this page for details on how it was called. If you
compile mozilla DEBUG, the message sent and received will be logged to the
console.
<p>This works by calling a SOAP service listed on
<A href="http://www.xmethods.com">X Methods Website</A> using the low-level
SOAP API in Mozilla.
<p>Since this service is not friendly to untrusted applets, it may not be
called without requesting additional privileges from the user. It can be
made friendly by accepting the verifySource header or by loading the page
and proxy from the domain of the service.
<p>Experimenters may wish to add other tests which exercize services, with
specific user interfaces such as the one in this test.
<SCRIPT>
var currentRequest;
function requestNews(value) {
document.getElementById('BUTTON').value = "Wait...";
var s = new SOAPCall();
s.transportURI = "http://www.SoapClient.com/xml/SQLDataSoap.WSDL";
s.actionURI = "/SQLDataSRL";
s.encode(0, "ProcessSRL", "http://www.SoapClient.com/xml/SQLDataSoap.xsd",
0, null,
2, new Array(new SOAPParameter("/xml/news.sri","SRLFile"),
new SOAPParameter(value,"RequestName")));
if (currentRequest != null) { currentRequest.abort(); }
//s.verifySourceHeader = true;
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
currentRequest = s.asyncInvoke(gotnews);
}
function gotnews(resp, call, status) {
document.getElementById('BUTTON').value = "Request News";
// Faulure, call did not complete
if (status != 0) {
alert("Error completion: " + status);
}
// Success, put the result into a new window.
else if (resp.fault == null) {
var ret = resp.getParameters(false, {});
nw = window.open(null,null,"status=no,toolbar=no,menubar=no,location=no");
nw.document.open();
nw.document.write(ret[0].value);
nw.document.close();
}
// There was a fault in the response
else {
var f = resp.fault;
var detail = f.detail;
var ds = new XMLSerializer();
var detailStr = detail ? ds.serializeToString(detail) : "";
alert("Fault namespace: " + f.faultNamespaceURI
+ "\nFault code: " + f.faultCode + "\nFault string: " + f.faultString
+ "\nFault actor: " + f.faultActor + "\nDetail: " + detailStr);
}
return true;
}
</SCRIPT>
<P>
<FORM>
<SELECT ID=SERVICE SIZE="1" name="RequestName">
<OPTION VALUE="7am" SELECTED>7am</OPTION>
<OPTION VALUE="newslinx">Newslinx</OPTION>
<OPTION VALUE="yahoo">Yahoo</OPTION>
</SELECT>
<INPUT ID=BUTTON TYPE="button" VALUE="Request News" ONCLICK="requestNews(document.getElementById('SERVICE').value);">
</BODY>
</HTML>