|
| ||||||||||
| Tags: foreach loop, how to, java, mobile phone, webservice, windows phone |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to use java webservice in windows phone app
Code: namespace Medical_Representative_Project2,
{
public partial class Antocids : PhoneApplicationPage
{
ObservableCollection<Class1> p = new ObservableCollection<Class1>();
ProductsClient client = new ProductsClient();
public Antocids()
{
InitializeComponent();
// listBox1.DataContext = p;
client.getProdDetailsAsync();
client.getProdDetailsCompleted+=new EventHandler<getProdDetailsCompletedEventArgs>(client_getProdDetailsCompleted);
}
private void client_getProdDetailsCompleted(object sender, getProdDetailsCompletedEventArgs e)
{
//listBox1.ItemsSource = p;
//var prodresult = (from p in e.Result select p).ToList(); //this also not worked
listBox1.ItemsSource=p;
}
}
} |
|
#2
| |||
| |||
| Re: How to use java webservice in windows phone app
by looking at your code I have found you have not setup any P to and this is empty. I have created the JAVA webservice in windows phone without any issue and if I compare the both code I think you have not added ItemsSource in the constructor and then populate it when the worker is done. So to test this I would like to suggest you to add below code on your code and after that you can solve your issue, First of build the simple Person class like this: Code: class Person
{
public string Name { get; set; }
} ObservableCollection<Person> p = new ObservableCollection<Person>(); Once you define the P and after that create the Antocids code which given below: Code: public Antocids()
{
InitializeComponent();
listbox1.ItemsSource = p;
var worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
worker.RunWorkerAsync();
} Code: p.Add(new Person { Name = "Filip Ekberg" });
p.Add(new Person { Name = "Anders Andersson" } );
foreach(var p in e.Result)
{
p.Add(p);
} foreach(var p in e.Result) Code: {
p.Add(p);
} |
|
#3
| |||
| |||
| Re: How to use java webservice in windows phone app
Hello thanks for the replies and I have tried your code but this doesn’t helped me to solve mien issue. When I run your code as you said I have got the below error messages: Quote:
|
|
#4
| |||
| |||
| Re: How to use java webservice in windows phone app
Hello your getting this issue due to the ProdData and you should try to convert ProdData to product object and after that you won’t get this issue or error message. Try the below code inside the foreach loop: Code: var product = new product { Name = a.Name };
p.Add(product); Code: foreach (var a in e.Result)
{
p.Add(new product { Name = a.Name} );
} |
|
#5
| |||
| |||
| Re: How to use java webservice in windows phone app
Hello thanks for the replies but this I have got the different error message both code are not working. While I have tried the add the code in foreach loop I have got the below error message : Quote:
![]() |
|
#6
| |||
| |||
| Re: How to use java webservice in windows phone app
Hello thanks for posting error code and replying back. I think you’re very close to solve your issue. Ok on code e.Result is an Array of objects and these are ProdData type and you wanted to use this as own type "product". So to solve this I would like to suggest you to try to add and change the below code in ObservableCollection and then you can solve your error codes: Code: ObservableCollection<ProdData> p = new ObservableCollection<ProdData>();
And then in your foreach-loop you do this:
foreach (var a in e.Result)
{
p.Add(a);
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to use java webservice in windows phone app" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Security between flex+air and webservice | Isiah | Software Development | 5 | 09-07-2010 03:10 AM |
| Need a small webservice for my website. | Sarah Rogger | Technology & Internet | 4 | 15-06-2010 12:21 AM |
| Parsing XML WebService | Efigenio | Software Development | 4 | 03-03-2010 02:55 AM |
| Enable SOAP to webservice | Harshini | Software Development | 1 | 22-04-2009 11:53 PM |
| MiPhone M88 Wifi Quadband Pda Smart Phone with Windows Os6.0 & Java | monsitj | Portable Devices | 0 | 05-01-2009 10:59 AM |