0

I just finished working on the Android port of the iOS App that I have and now the client also wants to have a Windows Phone version just so they can have an App for all three markets and right now I'm not sure how to consume the Web Services as the "Add Service Reference" option has been removed for Windows Phone 8.1 apps. I don't know if there's any online alternatives that create a proxy class like what the "Add Service Reference" did, I tried using the Svcutil.exe option to generate my own proxy but when I imported the file it was littered with errors and undefined types that aren't available for Windows Phone projects. Other than the proxy route I was reading that HttpClient should work, but so far I haven't been able to have much success with it (below is what I tried but I keep getting an error, and this is a more simple service, where some of the other services are more complex). For the Android and iOS projects I was able to find some online generators that created the proxy classes from the WSDL files and I've been trying to see if there's something similar for WP8.1 but so far I've been unsuccessful.

 Public Shared Async Function GetSession() As Task
    Dim values As New List(Of KeyValuePair(Of String, String)) From {
        New KeyValuePair(Of String, String)("RepLogin", "username"),
        New KeyValuePair(Of String, String)("RepPass", "password")}
    Dim httpClient As New HttpClient(New HttpClientHandler())
    Dim requestString As String = mobileAddress + "?op=VerifyRep"
    Dim response As HttpResponseMessage = Await httpClient.PostAsync(requestString, New FormUrlEncodedContent(values))
    Debug.WriteLine(response)
    Dim responseString = Await response.Content.ReadAsStringAsync()
    Debug.WriteLine("response string contains: " + responseString)
End Function

And before anyone suggests that the Web Service should be updated from SOAP to a WCF or something else that really isn't a solution in this scenario since the client already has several Web Applications and now two mobile apps (the iOS and Android ones) that all use this Service without any issues and it's going to be hard to convince them that everything needs to be reworked just for the sake of getting a Windows Phone app up and running

Sal Aldana
  • 1,235
  • 4
  • 17
  • 39

1 Answers1

0

Okay, so I figured out my problem was that when I created the project I just chose the Windows Phone template, which uses the Windows Runtime in order to share code with a Windows 8.1 App as well (which I still don't know how they would share if you can't consume a web service but that's not for here). I created a new project using the Windows Phone Silverlight template and now I can add a Service Reference as normal, and since I'm not planning on creating a Windows App that will share code with the Windows Phone app this is the way to go. Thanks anyways.

Sal Aldana
  • 1,235
  • 4
  • 17
  • 39