Category talk:XML Web Services
From MDC
Hi All,
I am programing on using the java script ot access web service. I follow the example of Amazon(http://www.mozilla.org/projects/webservices/examples/mozilla-wsdl/index.html), but have problem on interface which return ComplexType - the call back function cannot be called. I compare the wsdl of Amazon sample and mine, found in the part of defining complex type, amazon sample uses the <xsd:all> to enclose the element, but mine use the <sequence> tag. (My wsdl was generated by Apache Axis automatically from java class.) Then I changed my wsdl, replace the sequence with the xsd:all. And the callback can be called. But problem is the return value has error(ns_error_failure). Even when I call a interface which only return int, the return value is always 0. ( I check the log of server, the server call was made, but return value was wrong)
I tested this problem for nearly one week, but can not solve it. Can anyone kindly help me? Thanks in advance.
My js code is here: function getAMark () // test by the way amazon uses {
//var aValue = "chinese";
if (!proxy) {
var listener = {
// gets called once the proxy has been instantiated
onLoad: function (aProxy)
{
proxy = aProxy;
proxy.setListener(listener);
requestBookmarks(1);
},
// gets called if an error occurs
onError: function (aError)
{
alert(aError);
},
// callback function is hardcoded to {methodname}Callback in
1.4beta
testCallback : function (aresult)
{
alert("enter callback, result="+aresult);
alert("a="+aresult.a+", b="+aresult.b);
}
};
createProxy(listener);
}
else {
requestBookmarks(1);
}
}
function createProxy(aCreationListener)
{
try {
var factory = new WebServiceProxyFactory();
factory.createProxyAsync('http://localhost:8080/coreWeb/wsdl/Test2.wsdl', "Test2", "", true, aCreationListener);
}
catch (ex) {
alert("test "+ ex);
}
}
function requestBookmarks(vp)
{
if (proxy) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
proxy.test();
alert("call complete!");
}
else {
alert("Error: Proxy set up not complete!");
}
}
Jackie Ju