none
Facing problem in getting Data from WCF services to my UI. RRS feed

  • Question

  • I am new in Node js, and I am using node.js in netbeans and trying for connection with the WCF services. I am getting response from WCF service to my console, but I want only Data value,how to resolve this??

    here is my code

    var express = require('express');
    var app = express();
    var parseString = require('xml2js').parseString;

            

    var BasicHttpBinding = require('wcf.js').BasicHttpBinding
            , Proxy = require('wcf.js').Proxy
            , binding = new BasicHttpBinding(
                    {
                    })

            , proxy = new Proxy(binding, "http://localhost:9877/IDBReport/basicHttp")
            , message = "<Envelope xmlns='http://schemas.xmlsoap.org/soap/envelope/'>" +
            "<Header />" +
            "<Body>" +
            "<OrderReport xmlns='http://tempuri.org/'>" +
            "<value>10.2</value>" +
            "<value>ABC</value>" +
            "<value>11/16/2016</value>" +
            "<value>11/16/2016</value>" +
            "<value>DGCX</value>" +
            "<value>Gold</value>" +
    //        "<value>OneDay</value>" +
            "<value>cvy</value>" +
            "<value>15.25</value>" +
            "<value>No Error</value>" +
            "</OrderReport>" +
            "</Body>" +
            "</Envelope>";

    proxy.send(message, "http://tempuri.org/IDBReport/OrderReport", function (response, ctx) {
         app.set("view engine", "jade");
        app.get('/', function (req, res) {
      res.render('aaa', {title: response});
         console.dir(response['UserID']);
       console.dir(response);
        
        });

    });

    var server = app.listen(3000, function (response, ctx) {
        console.log('Server is running..http://localhost:3000/');
    });

    and when I am running this program, the output I am getting in my console.......

    Server is running..http://localhost:3000/
    undefined
    '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><OrderReportResponse xmlns="http://tempuri.org/"><OrderReportResult>true</OrderReportResult><exeReport xmlns:a="http://schemas.datacontract.org/2004/07/Finsoltech_User" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:RecordData/></exeReport><nErrorCode>-1</nErrorCode><strErrorText>BS&#xD;\n</strErrorText></OrderReportResponse></s:Body></s:Envelope>'

    Thursday, November 17, 2016 7:22 AM

Answers

  • Hi gunjan,

    Based on your result, you have achieved calling WCF Service from node.js, and get the response correctly. Then the next step will to be retrieve the xml to get your expected string value.
    Based on your code, you used “require('xml2js').parseString”, and you got null value, it seems you have provided the wrong xml path.

    To get the result, I suggest you try something like below:

    var r=result["s:Envelope"]["s:Body"][0]. OrderReportResponse[0]. OrderReportResult[0];

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 18, 2016 5:10 AM

All replies

  • Maybe, you should think about using AJAX with JavaScript.
    Thursday, November 17, 2016 11:33 PM
  • Hi gunjan,

    Based on your result, you have achieved calling WCF Service from node.js, and get the response correctly. Then the next step will to be retrieve the xml to get your expected string value.
    Based on your code, you used “require('xml2js').parseString”, and you got null value, it seems you have provided the wrong xml path.

    To get the result, I suggest you try something like below:

    var r=result["s:Envelope"]["s:Body"][0]. OrderReportResponse[0]. OrderReportResult[0];

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 18, 2016 5:10 AM
  • Thank u Edward,

    its working but how to get data in my UI

    Server is running..http://localhost:3000/
    { 's:Envelope': 
       { '$': { 'xmlns:s': 'http://schemas.xmlsoap.org/soap/envelope/' },
         's:Body': [ [Object] ] } }
    '{"s:Envelope":{"$":{"xmlns:s":"http://schemas.xmlsoap.org/soap/envelope/"},"s:Body":[{"OrderReportResponse":[{"$":{"xmlns":"http://tempuri.org/"},"OrderReportResult":["true"],"exeReport":[{"$":{"xmlns:a":"http://schemas.datacontract.org/2004/07/Finsoltech_User","xmlns:i":"http://www.w3.org/2001/XMLSchema-instance"},"a:RecordData":[{"a:RecordName":[{"a:CreateTime":["2016-11-09T00:00:00"],"a:ExpiryDate":[{"$":{"i:nil":"true"}}],"a:ID":["-1"],"a:LastOperator":[{"$":{"i:nil":"true"}}],"a:ModifieTime":["0001-01-01T00:00:00"],"a:Name":[" 06DF34144"],"a:ProductName":[{"$":{"i:nil":"true"}}],"a:RecordGroup":["0"],"a:TickSize":["213725"],"a:UserId":["0"]},{"a:CreateTime":["2016-11-09T00:00:00"],"a:ExpiryDate":[{"$":{"i:nil":"true"}}],"a:ID":["-1"],"a:LastOperator":[{"$":{"i:nil":"true"}}],"a:ModifieTime":["0001-01-01T00:00:00"],"a:Name":[" 06DF34145"],"a:ProductName":[{"$":{"i:nil":"true"}}],"a:RecordGroup":["0"],"a:TickSize":["213775"],"a:UserId":["0"]}]}]}],"nErrorCode":["0"],"strErrorText":[{"$":{"i:nil":"true","xmlns:i":"http://www.w3.org/2001/XMLSchema-instance"}}]}]}]}}'

     

    this is output which i am getting from the same program. I am trying to get the values in my UI (jade file in node.js).

    Friday, November 18, 2016 6:23 AM
  • Hi gunjan,

    For getting Data value from WCF response, I am glad the suggestion works for you, and I would suggest you mark my reply as answer.

    For new issue showing data in UI, I am afraid it is not related with WCF, and it is more related with Node.js and express, I would suggest you go to node.js forum, they are more familiar with it.

    Thanks for your understanding.

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 21, 2016 2:30 AM
  • this is output which i am getting from the same program. I am trying to get the values in my UI (jade file in node.js).

    Maybe, you need to learn basic JavaScript and how to use JQuery. It looks like you are in too deep, and you have the cart before the horse

    https://forums.asp.net/130.aspx/1?HTML+CSS+and+JavaScript

    Monday, November 21, 2016 2:43 AM
  • I think u dont know about Node.js... First go n see prblm is different.

    Monday, November 21, 2016 5:18 AM
  • I think u dont know about Node.js... First go n see prblm is different.

    And I probably don't want to know either. It looks like you are in over your head, and at best, you need to post to a Node.Js forum, since this is the WCF forum that has nothing to do with JavaScript in any format being used concerning the UI.

    Monday, November 21, 2016 12:18 PM
  • U man... just get lost from here.... Dont post such stupidity of urs here.
    Tuesday, November 22, 2016 6:31 AM
  • U man... just get lost from here.... Dont post such stupidity of urs here.

    Yeah and the cow jumped over the moon with you riding it too. This forum is NOT a Node.Js forum. Why you keep posting like it is is a mystery? If there is any stupidity going on here it is you not being able to comprehend or refusing to post to a correct forum when you are being told where to post.  
    Tuesday, November 22, 2016 1:56 PM