Invoking Axis webservice with enyo

Hi,

I've created a webservice that is invoked via Axis. If I call it using my internet navigator it works properly. The url is:

http://localhost:8080/hphis/axis/MobileDevicesService?method=getPatientList

But I'm trying to invoke it with enyo and it doesn´t work. I don´t know what is the problem. I attach the code I've created to invoke it :
enyo.kind({
name: "ServiceGetPatientBox",
kind: "enyo.WebService",
url: "http://localhost:8080/hphis/axis/MobileDevicesService?method=getPatientList",
handleAs:"xml",
headers:'{"Username":"mmiranda","Password":"nacho12","centro":"GEN"}',
onResponse: "gotListaPacientes",
onError: "gotListaPacientesFailure",

gotListaPacientes: function (inSender, inResponse, inRequest)
{
alert ("Great");
},

gotListaPacientesFailure: function ()
{
alert ("Error");
}
});
To invoke the webservice:
var service = new ServiceGetPatientBox();
service.send ();
Thanks for your help!!!

Comments

  • I have the most luck doing something like (note I am still drugged up in a hospital bed, so you may need to do some tweaking on this):
    enyo.kind({
    name: "MyApp",
    kind: enyo.Control, // or enyo.FittableRows or whatever you want
    components: [
    {name: "myWeb", kind: enyo.WebService, url: "theUrl", handleAs: "xml", headers: "theHeaders", onResponse: "gotWebResponse", onError: "gotWebError"},
    {kind: enyo.Button, content: "GO", ontap: "goWeb"}
    ],
    goWeb: function() {
    this.$.myWeb.send();
    },
    gotWebResponse: function(inSender, inResponse) {
    this.log("SUCCESS");
    },
    gotWebError: function(inSender, inStatus) {
    this.log("FAIL");
    }
    });
    The point is that the handlers for the WebService are generally expected to be in the owner of the WebService, not the WebService itself. Let me know if you need some more help.
  • Also of note: I'm not sure if you're running your code from your local filesystem (i.e. file://path/to/your/index.html) or not, but if you are the request will fail in most modern web browsers due to security restrictions that prevent file:// to http(s):// requests and vice-versa.
  • Hi,

    Thanks for your responses. I've tried both changes but it still doesn´t work. I've included the code of my mobile app in the same Jboss server and domain where the webservice is published, so the single domain data source problem should be fixed. I've included the webservice code in the main app.

    Right now, at least, the error return function is called, so I can see that enyo is trying to call the webservice, but the webservice is not called (I created a break point at the login system and it didn´t stop.

    Is there any kind of log to know which is exactly the problem?

    Thanks
  • edited April 2013
    Hi guys,

    Some update. I've tried this code and it returns to the success function:
    enyo.kind({
    name: "App",
    kind: enyo.Control,
    components: [
    {name: "myWeb", kind: enyo.WebService, url: "http://core5:8080/hphis/axis/MobileDevicesService", handleAs: "xml", onResponse: "gotWebResponse", onError: "gotWebError"},
    {kind: "enyo.Button", content: "GO", ontap: "goWeb"}
    ],
    goWeb: function() {
    this.$.myWeb.send();
    },
    gotWebResponse: function(inSender, inResponse) {
    alert("SUCCESS");
    },
    gotWebError: function(inSender, inStatus) {
    alert("FAIL");
    }
    });
    The problem comes when I try to add the header parameters and the normal parameters (as the method I'm invoking and its parameters. If I add this information to the code it returns to the error function. The code is as it follows:
    enyo.kind({
    name: "App",
    kind: enyo.Control,
    components: [
    {name: "myWeb", kind: enyo.WebService, url: "http://core5:8080/hphis/axis/MobileDevicesService", headers: {Username:"mmiranda",Password:"nacho12",centro:"GEN"}, handleAs: "xml", onResponse: "gotWebResponse", onError: "gotWebError"},
    {kind: "enyo.Button", content: "GO", ontap: "goWeb"}
    ],
    goWeb: function() {
    this.$.myWeb.send({
    method: 'getListaPacientes',
    listaID: '1'
    });
    },
    gotWebResponse: function(inSender, inResponse) {
    alert("SUCCESS");
    },
    gotWebError: function(inSender, inStatus) {
    alert("FAIL");
    }
    });
    Any clue of what's going wrong?
  • Everything seems right, which error returns?
  • Is your app being served from core5 port 8080? Is it possible you're hitting a cross-domain access error?
  • @lgallego I sent you an email asking about if there are any errors/differences in the server log between those two tests, but I was wondering if you might try something real quick.

    Try specifying the headers as a secondary argument to the .send() method:

    this.$.myWeb.send({method: "getListaPacientes", listaID: "1"}, {headers: {...}});

    I want to make sure it's not dropping the declared properties when it returns the new async object.
  • Hi everyone.

    The cross domain access error is solved because I've configured IE to allow it. Anyway, I inserted the code of my enyo app in the same domain, and the result is the same.

    About inserting the headers and parameters in the call, the result is the same: the error javascript function is invoked.

    The problem is the parameter arguments and not the headers. The code error returned is 500.
  • internal server error... Check the headers and parameters are right, and they're being handled properly in the server.
  • You might want to turn off cachebusting, as the server might not like that.
  • Ey guys. Thanks for all. Actually it was the cachebusting parameter. As it includes a parameter without name the server considered it wrong syntax. Once I've disabled that property the webservice is invoked.

    Thanks for your time and help :-D
Sign In or Register to comment.