Added an error check and a test case that does not work, yet, because

xpconnect is saying that an array is an interface, I think.

SOAP not part of default build.
This commit is contained in:
rayw%netscape.com 2002-01-18 20:09:06 +00:00
Родитель 79e837703a
Коммит ca9319c937
6 изменённых файлов: 140 добавлений и 6 удалений

Просмотреть файл

@ -351,7 +351,9 @@ NS_IMETHODIMP
}
PRUint16 typevalue;
nativeSchemaURI.Assign(*nsSOAPUtils::kXSURI[mSchemaVersion]);
aSource->GetDataType(&typevalue);
nsresult rc = aSource->GetDataType(&typevalue);
if (NS_FAILED(rc))
return rc;
switch (typevalue) {
case nsIDataType::VTYPE_INT8:
if (mustBeComplex)
@ -488,7 +490,7 @@ NS_IMETHODIMP
nsIID* iid;
nsCOMPtr<nsISupports> ptr;
nsresult rc = aSource->GetAsInterface(&iid, getter_AddRefs(ptr));
rc = aSource->GetAsInterface(&iid, getter_AddRefs(ptr));
if (NS_FAILED(rc))
return rc;
if (iid->Equals(NS_GET_IID(nsIPropertyBag))) { // Only do explicit property bags for now.

Просмотреть файл

@ -33,7 +33,7 @@ function oncompletion(resp, call, status) {
}
else {
var ret = resp.getParameters(false, {});
nw = window.open();
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();

Просмотреть файл

@ -0,0 +1,65 @@
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>SOAP Test: Statistics</H1>
This passes an array to request the average and standard deviation.
<p>This works by calling a SOAP service listed on
<A href="http://www.xmethods.com">X Methods Website</A>. View the source of this
page for details on how it was called. If you compile mozilla DEBUG (you also need
MOZ_SOAP), the message sent and received will be logged to the console.
<p>Experimenters may wish to add other tests which exercize services, with specific
user interfaces such as the one in this test.
<SCRIPT>
var currentCall;
// Passed in as the response handler in the asynchronous case
// and called directly (see below) in the synchronous case
function oncompletion(resp, call, status) {
document.getElementById("BUTTON").value = "Call";
if (status != 0) {
alert("Error completion: " + status);
return true;
}
// Was there a SOAP fault in the response?
if (resp.fault != null) {
var f = resp.fault;
var element = f.element;
var ds = new XMLSerializer();
var elementStr = ds.serializeToString(element);
alert("Fault:\nFault code: " + f.faultCode + "\nFault string: " + f.faultString
+ "\nFault actor: " + f.faultActor + "\nDetail: " + elementStr);
}
else {
var ret = resp.getParameters(false, {})[0];
alert("Average:" + ret.average + " SD:" + ret.standardDeviation);
}
return true;
}
function makeCall(values) {
var s = new SOAPCall();
// The targetObjectURI, methodName and destinatioName are mandatory.
// The actionURI is optional.
s.transportURI = "http://213.23.125.181:8080/RPC";
// Set the parameters on the call object. Note that in this case,
// the last parameter is an object that will be serialized into
// a struct parameter. It does not have a parameter wrapper because
// we don't need it to be named
s.encode(0, "getStatistics", "urn:SpheonJSOAPStatistics", 0, null, 1, new Array(new SOAPParameter(new Array(1.1,2.2,3.3,4.4,5.5),"values")));
if (currentCall != null) { currentCall.abort(); }
document.getElementById("BUTTON").value = "Wait";
currentCall = s.asyncInvoke(oncompletion);
}
</SCRIPT>
<P>
<FORM>
<INPUT ID=BUTTON TYPE="button" VALUE="Call" ONCLICK="makeCall(new Array(1.1,2.2,3.3,4.4,5.5));">
</BODY>
</HTML>

Просмотреть файл

@ -351,7 +351,9 @@ NS_IMETHODIMP
}
PRUint16 typevalue;
nativeSchemaURI.Assign(*nsSOAPUtils::kXSURI[mSchemaVersion]);
aSource->GetDataType(&typevalue);
nsresult rc = aSource->GetDataType(&typevalue);
if (NS_FAILED(rc))
return rc;
switch (typevalue) {
case nsIDataType::VTYPE_INT8:
if (mustBeComplex)
@ -488,7 +490,7 @@ NS_IMETHODIMP
nsIID* iid;
nsCOMPtr<nsISupports> ptr;
nsresult rc = aSource->GetAsInterface(&iid, getter_AddRefs(ptr));
rc = aSource->GetAsInterface(&iid, getter_AddRefs(ptr));
if (NS_FAILED(rc))
return rc;
if (iid->Equals(NS_GET_IID(nsIPropertyBag))) { // Only do explicit property bags for now.

Просмотреть файл

@ -33,7 +33,7 @@ function oncompletion(resp, call, status) {
}
else {
var ret = resp.getParameters(false, {});
nw = window.open();
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();

Просмотреть файл

@ -0,0 +1,65 @@
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>SOAP Test: Statistics</H1>
This passes an array to request the average and standard deviation.
<p>This works by calling a SOAP service listed on
<A href="http://www.xmethods.com">X Methods Website</A>. View the source of this
page for details on how it was called. If you compile mozilla DEBUG (you also need
MOZ_SOAP), the message sent and received will be logged to the console.
<p>Experimenters may wish to add other tests which exercize services, with specific
user interfaces such as the one in this test.
<SCRIPT>
var currentCall;
// Passed in as the response handler in the asynchronous case
// and called directly (see below) in the synchronous case
function oncompletion(resp, call, status) {
document.getElementById("BUTTON").value = "Call";
if (status != 0) {
alert("Error completion: " + status);
return true;
}
// Was there a SOAP fault in the response?
if (resp.fault != null) {
var f = resp.fault;
var element = f.element;
var ds = new XMLSerializer();
var elementStr = ds.serializeToString(element);
alert("Fault:\nFault code: " + f.faultCode + "\nFault string: " + f.faultString
+ "\nFault actor: " + f.faultActor + "\nDetail: " + elementStr);
}
else {
var ret = resp.getParameters(false, {})[0];
alert("Average:" + ret.average + " SD:" + ret.standardDeviation);
}
return true;
}
function makeCall(values) {
var s = new SOAPCall();
// The targetObjectURI, methodName and destinatioName are mandatory.
// The actionURI is optional.
s.transportURI = "http://213.23.125.181:8080/RPC";
// Set the parameters on the call object. Note that in this case,
// the last parameter is an object that will be serialized into
// a struct parameter. It does not have a parameter wrapper because
// we don't need it to be named
s.encode(0, "getStatistics", "urn:SpheonJSOAPStatistics", 0, null, 1, new Array(new SOAPParameter(new Array(1.1,2.2,3.3,4.4,5.5),"values")));
if (currentCall != null) { currentCall.abort(); }
document.getElementById("BUTTON").value = "Wait";
currentCall = s.asyncInvoke(oncompletion);
}
</SCRIPT>
<P>
<FORM>
<INPUT ID=BUTTON TYPE="button" VALUE="Call" ONCLICK="makeCall(new Array(1.1,2.2,3.3,4.4,5.5));">
</BODY>
</HTML>