Fixed infinite loop in struct decoding, added test case for struct decoding.

SOAP is not part of default build.
This commit is contained in:
rayw%netscape.com 2002-01-18 23:09:15 +00:00
parent 520175690b
commit 85845b7611
4 changed files with 144 additions and 0 deletions

View File

@ -1302,6 +1302,10 @@ NS_IMETHODIMP
rc = c->AddProperty(name, value);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIDOMElement> nextchild;
nsSOAPUtils::GetNextSiblingElement(child, getter_AddRefs(nextchild));
child = nextchild;
}
nsCOMPtr<nsIPropertyBag> pb;
c->GetPropertyBag(getter_AddRefs(pb));

View File

@ -0,0 +1,68 @@
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>SOAP Test: Headline News</H1>
The entered element will be requested and the info displayed. This service found 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].value;
alert("atomicnumber: " + ret.atomicnumber + ", symbol: " + ret.symbol + ", name: " + ret.name + ", mass: " + ret.mass + ", melting point: " + ret.meltingPoint + ", boiling point: " + ret.boilingPoint + ", found: " + ret.found);
}
return true;
}
function makeCall(symbol) {
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, "getElementBySymbol", "urn:SpheonJSOAPChemistry", 0, null,
1, new Array(new SOAPParameter(symbol,"symbol")));
if (currentCall != null) { currentCall.abort(); }
document.getElementById('BUTTON').value = "Wait...";
currentCall = s.asyncInvoke(oncompletion);
}
</SCRIPT>
<P>
<FORM>
<INPUT
<INPUT ID=ELEMENT TYPE="text">
<INPUT ID=BUTTON TYPE="button" VALUE="Call" ONCLICK="makeCall(document.getElementById('ELEMENT').value);">
</BODY>
</HTML>

View File

@ -1302,6 +1302,10 @@ NS_IMETHODIMP
rc = c->AddProperty(name, value);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsIDOMElement> nextchild;
nsSOAPUtils::GetNextSiblingElement(child, getter_AddRefs(nextchild));
child = nextchild;
}
nsCOMPtr<nsIPropertyBag> pb;
c->GetPropertyBag(getter_AddRefs(pb));

View File

@ -0,0 +1,68 @@
<HTML>
<HEAD>
</HEAD>
<BODY>
<H1>SOAP Test: Headline News</H1>
The entered element will be requested and the info displayed. This service found 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].value;
alert("atomicnumber: " + ret.atomicnumber + ", symbol: " + ret.symbol + ", name: " + ret.name + ", mass: " + ret.mass + ", melting point: " + ret.meltingPoint + ", boiling point: " + ret.boilingPoint + ", found: " + ret.found);
}
return true;
}
function makeCall(symbol) {
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, "getElementBySymbol", "urn:SpheonJSOAPChemistry", 0, null,
1, new Array(new SOAPParameter(symbol,"symbol")));
if (currentCall != null) { currentCall.abort(); }
document.getElementById('BUTTON').value = "Wait...";
currentCall = s.asyncInvoke(oncompletion);
}
</SCRIPT>
<P>
<FORM>
<INPUT
<INPUT ID=ELEMENT TYPE="text">
<INPUT ID=BUTTON TYPE="button" VALUE="Call" ONCLICK="makeCall(document.getElementById('ELEMENT').value);">
</BODY>
</HTML>