Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
1.00/5 (1 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
Updated 28-Mar-12 0:54am
v2

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 ?
 
Share this answer
 
Comments
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.
 
Share this answer
 
Comments
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.
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 asp.net 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 :

C#
[ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetItemInfo(string Category);//this is your function
    }
    [DataContract]
    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:
C#
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);
            conn.Open();
            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"]);
            }
            conn.Close();
            return items.Info;
        }
    }


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

C#
private void btnFind_Click(object sender, RoutedEventArgs e)
        {
            Service1Client service = new Service1Client();
            service.GetItemInfoAsync(txt1.Text);
            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.
 
Share this answer
 
Comments
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?
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900