зеркало из https://github.com/mozilla/pjs.git
Added encoding of untyped arrays. Fixed test html.
SOAP is not part of default build.
This commit is contained in:
Родитель
56bb80f8db
Коммит
e29bc6f1dc
|
@ -613,11 +613,9 @@ NS_IMETHODIMP
|
|||
if (NS_FAILED(rc)) return rc;\
|
||||
value.Append(nsSOAPUtils::kQualifiedSeparator);\
|
||||
value.Append(k##SOAPType##SchemaType);\
|
||||
if (count) { \
|
||||
value.Append(NS_LITERAL_STRING("[") + \
|
||||
NS_ConvertUTF8toUCS2(nsPrintfCString("%d", count)) + \
|
||||
NS_LITERAL_STRING("]")); \
|
||||
} \
|
||||
value.Append(NS_LITERAL_STRING("[") + \
|
||||
NS_ConvertUTF8toUCS2(nsPrintfCString("%d", count)) + \
|
||||
NS_LITERAL_STRING("]")); \
|
||||
rc = (*aReturnValue)->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[mSOAPVersion], kSOAPArrayTypeAttribute, value);\
|
||||
if (NS_FAILED(rc)) return rc;\
|
||||
XPType* values = NS_STATIC_CAST(XPType*, array);\
|
||||
|
@ -670,14 +668,39 @@ NS_IMETHODIMP
|
|||
case nsIDataType::VTYPE_ASTRING:
|
||||
ENCODE_SIMPLE_ARRAY(nsAString, String, "%s",
|
||||
NS_ConvertUCS2toUTF8(values[i]).get())
|
||||
case nsIDataType::VTYPE_ARRAY:
|
||||
case nsIDataType::VTYPE_INTERFACE_IS:
|
||||
if (iid.Equals(NS_GET_IID(nsIVariant))) { // Only do variants for now.
|
||||
nsAutoString value;
|
||||
rc = nsSOAPUtils::MakeNamespacePrefix(*aReturnValue, *nsSOAPUtils::kXSURI[mSchemaVersion], value);
|
||||
if (NS_FAILED(rc)) return rc;
|
||||
value.Append(nsSOAPUtils::kQualifiedSeparator);
|
||||
value.Append(kAnyTypeSchemaType);
|
||||
value.Append(NS_LITERAL_STRING("[") +
|
||||
NS_ConvertUTF8toUCS2(nsPrintfCString("%d", count)) +
|
||||
NS_LITERAL_STRING("]"));
|
||||
rc = (*aReturnValue)->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[mSOAPVersion], kSOAPArrayTypeAttribute, value);
|
||||
if (NS_FAILED(rc)) return rc;
|
||||
nsIVariant** values = NS_STATIC_CAST(nsIVariant**, array);
|
||||
nsCOMPtr<nsIDOMElement> dummy;
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
rc = aEncoding->Encode(values[i],
|
||||
kEmpty,
|
||||
kEmpty,
|
||||
nsnull,
|
||||
aAttachments,
|
||||
*aReturnValue,
|
||||
getter_AddRefs(dummy));
|
||||
if (NS_FAILED(rc)) return rc;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
// Don't support these array types just now (needs more work).
|
||||
case nsIDataType::VTYPE_WCHAR:
|
||||
case nsIDataType::VTYPE_ID:
|
||||
case nsIDataType::VTYPE_VOID:
|
||||
case nsIDataType::VTYPE_EMPTY:
|
||||
case nsIDataType::VTYPE_INTERFACE_IS:
|
||||
case nsIDataType::VTYPE_INTERFACE:
|
||||
case nsIDataType::VTYPE_ARRAY:
|
||||
break;
|
||||
}
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<HEAD>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<H1>SOAP Test: Headline News</H1>
|
||||
<H1>SOAP Test: Elements</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
|
||||
|
|
|
@ -33,7 +33,7 @@ function oncompletion(resp, call, status) {
|
|||
+ "\nFault actor: " + f.faultActor + "\nDetail: " + elementStr);
|
||||
}
|
||||
else {
|
||||
var ret = resp.getParameters(false, {})[0];
|
||||
var ret = resp.getParameters(false, {})[0].value;
|
||||
alert("Average:" + ret.average + " SD:" + ret.standardDeviation);
|
||||
}
|
||||
return true;
|
||||
|
@ -50,7 +50,10 @@ function makeCall(values) {
|
|||
// 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")));
|
||||
p = new SOAPParameter();
|
||||
p.value = values;
|
||||
p.name = "values";
|
||||
s.encode(0, "getStatistics", "urn:SpheonJSOAPStatistics", 0, null, 1, new Array(p));
|
||||
|
||||
if (currentCall != null) { currentCall.abort(); }
|
||||
document.getElementById("BUTTON").value = "Wait";
|
||||
|
|
|
@ -613,11 +613,9 @@ NS_IMETHODIMP
|
|||
if (NS_FAILED(rc)) return rc;\
|
||||
value.Append(nsSOAPUtils::kQualifiedSeparator);\
|
||||
value.Append(k##SOAPType##SchemaType);\
|
||||
if (count) { \
|
||||
value.Append(NS_LITERAL_STRING("[") + \
|
||||
NS_ConvertUTF8toUCS2(nsPrintfCString("%d", count)) + \
|
||||
NS_LITERAL_STRING("]")); \
|
||||
} \
|
||||
value.Append(NS_LITERAL_STRING("[") + \
|
||||
NS_ConvertUTF8toUCS2(nsPrintfCString("%d", count)) + \
|
||||
NS_LITERAL_STRING("]")); \
|
||||
rc = (*aReturnValue)->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[mSOAPVersion], kSOAPArrayTypeAttribute, value);\
|
||||
if (NS_FAILED(rc)) return rc;\
|
||||
XPType* values = NS_STATIC_CAST(XPType*, array);\
|
||||
|
@ -670,14 +668,39 @@ NS_IMETHODIMP
|
|||
case nsIDataType::VTYPE_ASTRING:
|
||||
ENCODE_SIMPLE_ARRAY(nsAString, String, "%s",
|
||||
NS_ConvertUCS2toUTF8(values[i]).get())
|
||||
case nsIDataType::VTYPE_ARRAY:
|
||||
case nsIDataType::VTYPE_INTERFACE_IS:
|
||||
if (iid.Equals(NS_GET_IID(nsIVariant))) { // Only do variants for now.
|
||||
nsAutoString value;
|
||||
rc = nsSOAPUtils::MakeNamespacePrefix(*aReturnValue, *nsSOAPUtils::kXSURI[mSchemaVersion], value);
|
||||
if (NS_FAILED(rc)) return rc;
|
||||
value.Append(nsSOAPUtils::kQualifiedSeparator);
|
||||
value.Append(kAnyTypeSchemaType);
|
||||
value.Append(NS_LITERAL_STRING("[") +
|
||||
NS_ConvertUTF8toUCS2(nsPrintfCString("%d", count)) +
|
||||
NS_LITERAL_STRING("]"));
|
||||
rc = (*aReturnValue)->SetAttributeNS(*nsSOAPUtils::kSOAPEncURI[mSOAPVersion], kSOAPArrayTypeAttribute, value);
|
||||
if (NS_FAILED(rc)) return rc;
|
||||
nsIVariant** values = NS_STATIC_CAST(nsIVariant**, array);
|
||||
nsCOMPtr<nsIDOMElement> dummy;
|
||||
for (PRUint32 i = 0; i < count; i++) {
|
||||
rc = aEncoding->Encode(values[i],
|
||||
kEmpty,
|
||||
kEmpty,
|
||||
nsnull,
|
||||
aAttachments,
|
||||
*aReturnValue,
|
||||
getter_AddRefs(dummy));
|
||||
if (NS_FAILED(rc)) return rc;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
// Don't support these array types just now (needs more work).
|
||||
case nsIDataType::VTYPE_WCHAR:
|
||||
case nsIDataType::VTYPE_ID:
|
||||
case nsIDataType::VTYPE_VOID:
|
||||
case nsIDataType::VTYPE_EMPTY:
|
||||
case nsIDataType::VTYPE_INTERFACE_IS:
|
||||
case nsIDataType::VTYPE_INTERFACE:
|
||||
case nsIDataType::VTYPE_ARRAY:
|
||||
break;
|
||||
}
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<HEAD>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<H1>SOAP Test: Headline News</H1>
|
||||
<H1>SOAP Test: Elements</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
|
||||
|
|
|
@ -33,7 +33,7 @@ function oncompletion(resp, call, status) {
|
|||
+ "\nFault actor: " + f.faultActor + "\nDetail: " + elementStr);
|
||||
}
|
||||
else {
|
||||
var ret = resp.getParameters(false, {})[0];
|
||||
var ret = resp.getParameters(false, {})[0].value;
|
||||
alert("Average:" + ret.average + " SD:" + ret.standardDeviation);
|
||||
}
|
||||
return true;
|
||||
|
@ -50,7 +50,10 @@ function makeCall(values) {
|
|||
// 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")));
|
||||
p = new SOAPParameter();
|
||||
p.value = values;
|
||||
p.name = "values";
|
||||
s.encode(0, "getStatistics", "urn:SpheonJSOAPStatistics", 0, null, 1, new Array(p));
|
||||
|
||||
if (currentCall != null) { currentCall.abort(); }
|
||||
document.getElementById("BUTTON").value = "Wait";
|
||||
|
|
Загрузка…
Ссылка в новой задаче