简体   繁体   English

Windows Phone-使用Java Web服务

[英]Windows Phone - Consume Java Web Service

I'm a beginner in C#, my Visual Studio is the 2010, my version of Windows Phone 7 is researched on the internet and in this version of the command "async" only works Visual Studio 12 up. 我是C#的初学者,我的Visual Studio是2010,我的Windows Phone 7版本已在Internet上进行了研究,在此版本的“异步”命令中,只有Visual Studio 12才能运行。

You have any other alternative? 您还有其他选择吗?

I can map the webservice with references service, but the return is always zero, but in Android works, what the error might be? 我可以使用引用服务映射Web服务,但返回值始终为零,但是在Android中,错误可能是什么?

I changed the code to stay as he told me, but the error continues to occur: Unmarshalling Error: unexpected element (uri: "webservices.com.br/"; site: "parameter1"). 我按照他的指示更改了代码,但错误仍然发生:编组错误:意外元素(uri:“ webservices.com.br/”;站点:“ parameter1”)。 The expected elements are <{} parameter2>, <{} parameter1> The following source code: 期望的元素是<{} parameter2>,<{} parameter1>以下源代码:

public partial class MainPage : PhoneApplicationPage{
  wsServico.cadastroTo cadastroTo = null; 

  public MainPage(){
    InitializeComponent();
  }

  private void button1_Click(object sender, RoutedEventArgs e){
    wsServico.TesteJavaWsClient ws = new wsServico.TesteJavaWsClient();
    ws.returnServicoAsync("A", "B");         
    ws.returnServicoCompleted += new EventHandler<wsServico.returnServicoCompletedEventArgs>(ws_returnServicoCompleted);

  }

  void ws_returnServicoCompleted(object sender, wsServico.returnServicoCompletedEventArgs e){
    cadastroTo = e.Result;
    textBox1.Text = cadastroTo.cadastroId.ToString();        

  }

}

You are setting your textbox too early - before the web service call returns. 您设置文本框的时间太早-在Web服务调用返回之前。 After you fire off the web service call, you are immediately setting your textbox, which will be empty. 触发Web服务调用后,您将立即设置文本框,该文本框为空。 You want to set the value in the ws_returnServicoCompleted method, after the web service has returned results. Web服务返回结果后,您想在ws_returnServicoCompleted方法中设置值。

private void button1_Click(object sender, RoutedEventArgs e){
    wsServico.TesteJavaWsClient ws = new wsServico.TesteJavaWsClient();
    ws.returnServicoAsync("A", "B");         
    ws.returnServicoCompleted += new EventHandler<wsServico.returnServicoCompletedEventArgs>(ws_returnServicoCompleted);
}

void ws_returnServicoCompleted(object sender,
   wsServico.returnServicoCompletedEventArgs e){
       cadastroTo = e.Result;
       cadastroTo.cadastroId.ToString();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM