Click here to Skip to main content
13,296,407 members (55,851 online)
Rate this:
Please Sign up or sign in to vote.
I am currently developing an application for Windows Phone 7. I do not know much about webservices.
There is a webservice that i want to use which is in the form http://"something".wsdl
This service hosts a set of methods, which I am aware of.

I have added this as Service Reference to my WP7 project. But I am not able to access any of the methods. Am I missing something? Please help

Thank you
Posted 28-Mar-12 1:38am
Updated 28-Mar-12 1:54am
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Now I want you to do few things and come back:

1. Check this web service in some windows console application and see if you are able to access the required methods

2. Now when you add the web service to your WP7 project, is there any broken link/wrong link/unavailable reference image seen on that refereed web service assembly. If not just try to see in the Object Browser if that web service assembly is showing the methods.

3. Have you able to create object for the web service class you want to use ?
VigneshPT 8-Apr-12 3:47am
Actually it is not showing the methods in the object browser. I do not know why. But there is a stub file which was generated by the wsdl tool, which if included, works well in using the service, but this can not be included in wp7 project. Please help regarding this.
VigneshPT 8-Apr-12 3:48am
If you could provide me your e-mail or contact, I could explain the problem in a more detailed manner. I have not found the solution yet.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

CHill60 23-Sep-13 15:12pm
It's considered quite rude to post links to your own articles as solutions to year-old questions. I see someone has already downvoted this response
Praveen Maniyath 26-Sep-13 1:50am
Hi CHill ,
I am sorry but since i faced the same issue,and finally got solution by the codes that i shared in the article.I thought this mite be helpful.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

look man i don't understand becuase i need to see the code but let me help you:

1st- user WCF it is more professional than web-service and also it is a kind of web service you can do that by right click on your solution -> Add --> New Project -> go to Web under Visual C# and add new empty web application

2nd- right click on this new web app -> add -> New Item also go to web under visual C# and choose WCF Service and add it and don'y forget to build it the go to your phone project right click add service reference click Discover after the the text box address will be filled with the path of the WCF automatically then press ok but dont forget when you change anything in the WCF you have to update the service by right on youServiceNameservicereference under service reference right click update

3rd- in the Iservice1.CS you have to add your class as follows :

    public interface IService1
        string GetItemInfo(string Category);//this is your function
    public class Items
        public string ID { get; set; }
        public string Category { get; set; }
        public string Info { get; set; }
        public int Quantity { get; set; }
        public string Mark { get; set; }
        public int Price { get; set; }

and in the IService1.svc.cs add the function ass follows:
public class Service1 : IService1
        string connection = ConfigurationManager.ConnectionStrings["Connection"].ToString();
        public string GetItemInfo(string Category)
            Items items = new Items();
            SqlDataReader reader = null;
            SqlCommand cmd = new SqlCommand("select top(1) ID, Category, Info, Mark, Quantity, Price from item where category ='" + Category + "'");
            SqlConnection conn = new SqlConnection(connection);
            cmd.Connection = conn;
            reader = cmd.ExecuteReader();
            if (reader.Read())
                items = new Items();
                items.ID = (string)reader["ID"];
                items.Category = reader["Category"].ToString().Trim();
                items.Info = reader["info"].ToString().Trim();
                items.Mark = reader["Mark"].ToString().Trim();
                items.Quantity = Convert.ToInt16(reader["Quantity"]);
                items.Price = Convert.ToInt16(reader["Price"]);
            return items.Info;

4th- in the code behind of your page use the function ass follows:

private void btnFind_Click(object sender, RoutedEventArgs e)
            Service1Client service = new Service1Client();
            service.GetItemInfoCompleted += new EventHandler<GetItemInfoCompletedEventArgs>(service_GetItemInfoCompleted);
        void service_GetItemInfoCompleted(object sender, GetItemInfoCompletedEventArgs e)
            txb1.Text = e.Result;

don't forget when you make changes in the service update the service reference in the mobile application.
best regards and don't forget to vote if this help you.
VigneshPT 29-Mar-12 12:00pm
I am not creating a web service. I only want to consume an existing web service. I read that there is something problem with the binding. Can somebody please explain?
Rate this: bad
Please Sign up or sign in to vote.

Solution 5

use web client for consuming your web service.

webclient wc = new webclient();
wc.DownloadstringCompleted += new handlername (Method name);
wc.downloadStringasyc(new uri (your url));

hope this will help you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171207.1 | Last Updated 20 Feb 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100