Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to making async call to proxy webreference created from asmx webservice

how to making async call to proxy webreference created from asmx webservice

Scheduled Pinned Locked Moved C#
mobiletutorial
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ArunHanu
    wrote on last edited by
    #1

    I have created proxy services by add web reference in my Xamarin.Droid project to access asmx webservice. Eg: I have a webservice for feature master when I make a direct request with URL "http://XX.XX.XXX.XXX/tabsaleswithdatasync.asmx/FeatureMaster" I am getting following info

    [{"msg":"","FeatureSlno":"2","Feature":"Fuel Used","DefaultValue":"","FeatureType":"B","Groups":"OverView","GroupOrder":"0","SubGroupOrder":"0","CategorySlno":"2","UtilisationSlno":"1","IconImagePath":"","LowerIsBetter":"0"},{"msg":"","FeatureSlno":"3","Feature":"Seating Capacity","DefaultValue":"","FeatureType":"B","Groups":"OverView","GroupOrder":"0","SubGroupOrder":"0","CategorySlno":"3","UtilisationSlno":"0","IconImagePath":"","LowerIsBetter":"0"}]

    I have written my method to get data EngageWebReference.TabSalesWithDataSync objProxy = new EngageWebReference.TabSalesWithDataSync(); objProxy.FeatureMasterCompleted += ObjProxy_FeatureMasterCompleted; objProxy.FeatureMasterAsync(); private void ObjProxy_CityMasterCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { // here I am getting XMLException as data at the root level is invalid. line 1 position 1. throw new NotImplementedException(); } Can anyone suggest how to make async call get the desired result into a variable eg: List res = new List res = GetFeatureMasterList();

    N 1 Reply Last reply
    0
    • A ArunHanu

      I have created proxy services by add web reference in my Xamarin.Droid project to access asmx webservice. Eg: I have a webservice for feature master when I make a direct request with URL "http://XX.XX.XXX.XXX/tabsaleswithdatasync.asmx/FeatureMaster" I am getting following info

      [{"msg":"","FeatureSlno":"2","Feature":"Fuel Used","DefaultValue":"","FeatureType":"B","Groups":"OverView","GroupOrder":"0","SubGroupOrder":"0","CategorySlno":"2","UtilisationSlno":"1","IconImagePath":"","LowerIsBetter":"0"},{"msg":"","FeatureSlno":"3","Feature":"Seating Capacity","DefaultValue":"","FeatureType":"B","Groups":"OverView","GroupOrder":"0","SubGroupOrder":"0","CategorySlno":"3","UtilisationSlno":"0","IconImagePath":"","LowerIsBetter":"0"}]

      I have written my method to get data EngageWebReference.TabSalesWithDataSync objProxy = new EngageWebReference.TabSalesWithDataSync(); objProxy.FeatureMasterCompleted += ObjProxy_FeatureMasterCompleted; objProxy.FeatureMasterAsync(); private void ObjProxy_CityMasterCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { // here I am getting XMLException as data at the root level is invalid. line 1 position 1. throw new NotImplementedException(); } Can anyone suggest how to make async call get the desired result into a variable eg: List res = new List res = GetFeatureMasterList();

      N Offline
      N Offline
      Nathan Minier
      wrote on last edited by
      #2

      Yeah...just a guess but your error is most likely related to the data being in JSON rather than XML. Try parsing with Newtonsoft, or pass an "Accept: application/xml" header.

      "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

      A 1 Reply Last reply
      0
      • N Nathan Minier

        Yeah...just a guess but your error is most likely related to the data being in JSON rather than XML. Try parsing with Newtonsoft, or pass an "Accept: application/xml" header.

        "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

        A Offline
        A Offline
        ArunHanu
        wrote on last edited by
        #3

        Thank you!! Do you mean I have to make change in Webservice ??

        L N 2 Replies Last reply
        0
        • A ArunHanu

          Thank you!! Do you mean I have to make change in Webservice ??

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Deserialize the result from the webservice to a .Net class:

          Newtonsoft.Json.JsonConvert.DeserializeObject

          It's a Nuget package you add to your project to get the dll references.

          "(I) am amazed to see myself here rather than there ... now rather than then". ― Blaise Pascal

          1 Reply Last reply
          0
          • A ArunHanu

            Thank you!! Do you mean I have to make change in Webservice ??

            N Offline
            N Offline
            Nathan Minier
            wrote on last edited by
            #5

            What Gerry said. Alternatively the agent you're using to make the request (such as HttpClient) can be configured to send custom accept headers, and if the web service supports it you can request the data in XML form instead, which was the second part of my suggestion.

            "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

            A 1 Reply Last reply
            0
            • N Nathan Minier

              What Gerry said. Alternatively the agent you're using to make the request (such as HttpClient) can be configured to send custom accept headers, and if the web service supports it you can request the data in XML form instead, which was the second part of my suggestion.

              "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

              A Offline
              A Offline
              ArunHanu
              wrote on last edited by
              #6

              As I am using ASMX I think I cant configure to return XML. I have JSON data returning. Is there any possibilities to consume JSON from webservice with an Async call. I am new to C# and Xamarin.

              N 1 Reply Last reply
              0
              • A ArunHanu

                As I am using ASMX I think I cant configure to return XML. I have JSON data returning. Is there any possibilities to consume JSON from webservice with an Async call. I am new to C# and Xamarin.

                N Offline
                N Offline
                Nathan Minier
                wrote on last edited by
                #7

                Yes, as I said and Gerry clarified. If you need help with the nuts and bolts we can provide that, but with the information you've given we don't even know how you're consuming the service, let alone any implementation details.

                "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

                A 1 Reply Last reply
                0
                • N Nathan Minier

                  Yes, as I said and Gerry clarified. If you need help with the nuts and bolts we can provide that, but with the information you've given we don't even know how you're consuming the service, let alone any implementation details.

                  "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

                  A Offline
                  A Offline
                  ArunHanu
                  wrote on last edited by
                  #8

                  Thank you, I was trying to consume ASMX web service as instructed in Xamarin ASMX Consuming an ASP.NET Web Service (ASMX) - Xamarin[^] I could make out the expected output was not as per the standards are given SOAP 1.1. So I have to modify the ASMX service Thank you again

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups