locked
How to return web service with success, failure method RRS feed

  • Question

  • User-712926555 posted

    Hi, 

    I have to create a android app. I am creating a web service  in .asmx, it will return in json format.

    ["message":"Login successfully",
             "username":"aravinth",
             "userid":1234,
             "organization":"M-ULink",
             "organizationId":124,
             "branch":"Salem-4 Roads",
             "branchId":432]

    But  I need to return the format like as below

    {
       "statusCode":200,
       "referenceAPI":"/hotel/login",
       "success":{
          "result":{
             "message":"Login successfully",
             "username":"myname",
             "userid":1234,
             "organization":"mycompany",
             "organizationId":124,
             "branch":"mybranch",
             "branchId":432
          }
       },
       "failure":{
          "message":""
       }
    }

    How to return web service in the above format in asp.net 4.0

    Thursday, August 23, 2018 3:09 PM

All replies

  • User753101303 posted

    Hi,

    And which type do you return currently? Copy/paste the json you want to http://json2csharp.com/. It will generate the suitable "RootObject" C# class for you.

    Thursday, August 23, 2018 7:20 PM
  • User1120430333 posted

    I have to create a android app. I am creating a web service in .asmx, it will return in json format.

    Legacy asmx ASP.NET Web service is not suited for mobile device solutions. ASP.NET WebApi is since it is Json based. 

    Friday, August 24, 2018 5:06 AM