locked
Adding WSDL to Windows 8 Store App RRS feed

  • Question

  • I have a Windows 7 project that I need to pull into a Windows 8 RT project. The project contains a Web References folder and a WSDL file as seen from the Solution Explorer. When I look in the Web References folder using Windows Explorer, I see a bunch of other files as well (*.xsd, Reference.map, and so on).

    I copied the Web References folder as a subdirectory to my Windows 8 RT project. If I just adding existing reference and specify the wsdl file, I don't get the other files. If I try to pull the wsdl file in using Add Service Reference, it seems like it's expecting me to type in the server address (sadly, the server is down at the moment).

    Is there a way to import everything in my Web References folder for my windows 8 RT project?

    Thanks,


    Randy

    Friday, November 1, 2013 2:15 PM

Answers

  • Even if you have a local WSDL file saved in your hard drive, the "Add Service Reference" option allows you to specify a local file too. You don't necessarily have to have a HTTP location to add the service reference. That is the correct way to add a reference to your WebService:

    Once you add your service reference you can consume the WebService using a code like below - notice that you can provide the endpoint address as a runtime parameter (txtOut is a simple text box that displays the response):

            private async void btnCallWS_Click(object sender, RoutedEventArgs e)
            {
                try 
                {
                    System.ServiceModel.EndpointAddress epAddress = new System.ServiceModel.EndpointAddress("http://<YourWebServer>/HelloWorldWebService/Service.asmx");
                    System.ServiceModel.BasicHttpBinding basicHttpBinding = new System.ServiceModel.BasicHttpBinding();
    
                    HelloWorldWebService.ServiceSoapClient client = new HelloWorldWebService.ServiceSoapClient(basicHttpBinding, epAddress);
                    HelloWorldWebService.HelloWorldResponse response = await client.HelloWorldAsync("test");
                    txtOut.Text = response.Body.HelloWorldResult.ToString() ;
                }
                catch (Exception oEx) 
                {
                    txtOut.Text = oEx.Message;
                }
            }


    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Friday, November 1, 2013 9:58 PM
    Moderator