Want to get rid of Google Ads, click here.
+ Reply to Thread
Results 1 to 10 of 10

Thread: Calling Web Services from SM7

  1. #1
    Senior Member
    Join Date
    Apr 2007
    Posts
    160

    Default Calling Web Services from SM7

    Hi,

    Not sure if this has already been asked, I have searched around without any success.

    Basically I'm setting up 2-way Web Services in and out of SM7, I have managed to successfully test incoming Web Services, it's just the outgoing I need to get my head around.

    I've read through the best practice document and think I'm nearly there, I just can't complete the end part and if anyone can shed some light I'd appreciate it.

    I have converted my WSDL to JS and I have created a JS record that creates a new variable for example:

    var CreateIncidentRequest = new system.library.TestIncident.CreateIncidentRequest( );

    I get in return: [object Object]

    If I understand this correctly, I have created an empty Object that will eventually be the 'requestObj' that gets passed to the invoke function once all the values I want passed over are contained.

    It's just that I am trying to populate the Object with my test values that will end up being the values within the Incident record that get saved within SM7.

    If someone could help with this last part I would appreciate it.

    Thanks a lot in advance.

  2. #2
    Junior Member kostanga's Avatar
    Join Date
    Nov 2008
    Posts
    1

    Default

    Hi,
    You are trying to set array value to string value. You can convert this value to string .

  3. #3
    Senior Member
    Join Date
    Apr 2007
    Posts
    160

    Default

    Hi,

    That's making sense - thanks.

    Been trying to get it to display the type but not having any luck. So once I have created the empty object, how would you recommend I start populating the fields within?

    Just wanted to confirm with anyone, when this line gets executed:

    var CreateIncidentRequest = new system.library.TestIncident.CreateIncidentRequest( );

    And I then execute the following line:

    print("Contents of Object is: "+CreateIncidentRequest);

    Should I see all the empty elements that were defined in the WSDL before the conversion, or should it display '[object Object]'?

    Obviously when I print an SCFile version I get to see all the commas etc....

    Cheers
    Last edited by Nosnibor35; 2010-04-07 at 15:34.

  4. #4
    Senior Member
    Join Date
    Apr 2006
    Location
    United States
    Posts
    178

    Default

    '[object Object]' is what you will see in this case--I usually modify the invoke function for testing outgoing web services by printing the xml representation that is created during the serialize function.

  5. #5
    Senior Member
    Join Date
    Apr 2007
    Posts
    160

    Default

    What I've managed to do so far is this:

    I've created the empty Object (as above) and using the following code I have populated all the fields I need:

    CreateIncidentRequest.Service = "Handheld Device";
    CreateIncidentRequest.Category = "incident";
    etc....

    But when I finalise the code with:

    var CreateIncidentResponse = TestIncident.invoke(CreateIncidentRequest);

    I get the following error:

    Script TestWebServices line 30: ERROR ReferenceError: TestIncident is not defined at char 1

    Line 30 is the var CreateIncident........ line above.

    I can't see exactly what I'm doing wrong here, so any help would be appreciated.

    Cheers

  6. #6
    Senior Member
    Join Date
    Apr 2006
    Location
    United States
    Posts
    178

    Default

    TestIncident needs to be defined as your service variable which usually is something like:
    var TestIncident = lib.<<generated ScriptLibrary Name like IncidentService>>.<<first function in generated ScriptLibrary like IncidentService>>();

  7. #7
    Senior Member
    Join Date
    Apr 2007
    Posts
    160

    Default

    Quote Originally Posted by jochocki View Post
    TestIncident needs to be defined as your service variable which usually is something like:
    var TestIncident = lib.<<generated ScriptLibrary Name like IncidentService>>.<<first function in generated ScriptLibrary like IncidentService>>();
    Hi,

    Following the best practice document, the only thing I saw was after you have defined the extaccess record, you convert it to JS and that will be the main ScriptLibrary record that will define the structure of the Object using the following line:

    var CreateIncidentRequest = new system.library.TestIncident.CreateIncidentRequest( );

    So now I have an Object called CreateIncidentRequest with all the Instances, I can then populate the properties with all my values as follows:

    CreateIncidentRequest.Service = "Handheld Device";

    I have tried the code that the document states, something like:

    CreateIncidentRequest.model.instance.header.Servic e.getValue...... etc but that isn't accepted. The closest is:

    CreateIncidentRequest.Service.getValue("Handheld Device");..... but that returns 'undefined'.

    I don't have the system with me at the moment otherwise I'd just paste the full code, I can do that tomorrow. I just think I'm missing a stage here.

    Cheers

  8. #8
    Senior Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    930

    Default

    The JS code you generated will tell you all about the attributes of the Object you want to create. There are several Object relevant to the request you want to make. The Service (which in an instance of the main object of the WSDL2JS) [the one you use as TestIncident] and the parse object (the record so to speak) which is the CreateIncidentRequest.

    Give me a call if you want to discuss in more detail...

  9. #9
    Junior Member
    Join Date
    Oct 2009
    Posts
    9

    Default

    Hi Nosnibor35:


    Try doing something like this:

    I'm not sure how it's because I don't have any access to SM, but I did some in this way. You have to create the object of the web service, then the object of the request, populate the request creating the model and the instance object and assigning, populate the model and the instance and then try to execute the function create.

    var proxy = new system.library.TestIncident.IncidentManagement( );
    var req = new system.library.TestIncident.CreateIncidentRequest( );
    var model = new system.library.TestIncident.IncidentManagementMode l();
    var instanace = new system.library.TestIncident.IncidentManagementMode l();

    req.setModel(model);
    req.setInstance(instance);

    instance.setIncidentID('IMXXXX');

    var response = new system.library.TestIncident.CreateIncidentResponse ( );
    response = proxy.createIncident(req);

    Hope it be useful.


    bye

  10. #10
    Senior Member
    Join Date
    Apr 2007
    Posts
    160

    Default

    Thanks very much for your replies, I'll give that a go. Very interesting that some of these important elements are missed from the document!

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts