.net 在WP7中调用普通web服务
我有正常的.NETWeb服务(不是WCF服务) 我已经使用服务引用将此服务添加到我的WP7项目中,因为我们没有。通常,我们将使用addservicereference选项添加WCF服务,但在这里,我使用addservicereference选项添加了普通Web服务 例如,我有这样的服务:.net 在WP7中调用普通web服务,.net,web-services,windows-phone-7,.net,Web Services,Windows Phone 7,我有正常的.NETWeb服务(不是WCF服务) 我已经使用服务引用将此服务添加到我的WP7项目中,因为我们没有。通常,我们将使用addservicereference选项添加WCF服务,但在这里,我使用addservicereference选项添加了普通Web服务 例如,我有这样的服务: public class Service1 { //local class variable public MsgHeader msh; //I hav
public class Service1
{
//local class variable
public MsgHeader msh;
//I have two functions like below:
[WebMethod]
public int Fun1()
{
return 1;
}
[WebMethod]
public int Fun2()
{
// Here i am checking msh(MsgHeader) values with the database.
//If this information is not correct i am not proceeding further.
// some calculations
return result; //returning some results
}
}
我在WP7中调用如下方法:
Class TestModel
{
public void TestFun1()
{
RS.Service1SoapClient objRS = new RS.RSService1SoapClient();
objRS.Fun1Completed += new EventHandler<RS.Fun1CompletedEventArgs>(objRS_Completed);
objRS.Fun1Async();
}
private void objRS_Completed(object sender, EventCompletedEventArgs e)
{
string str = e.Result;
responseEventArgs = new ResponseEventArgs();
responseEventArgs.response = e.Result;
System.Windows.Deployment.Current.Dispatcher.BeginInvoke(responseEventHandler, responseEventArgs);
}
}
我的问题是:
1) 我已经使用服务引用添加了普通的web服务,因为我们在VisualStudio2010Express for windows phone中没有添加web引用。是这样吗
2) 我已经使用服务引用添加了普通的web服务,如果这是一种正确的方法,我如何获得该变量msh
3) 我已经使用服务引用添加了正常的web服务,如果这不是一种正确的方法,我如何在WP7中调用正常的web服务
请帮帮我。
提前感谢。我认为您混淆了服务器上运行的web服务类和Visual Studio中“添加服务引用”对话框生成的代理类 proxy类公开了一些方法,这些方法提供了在web服务上调用[WebMethod]方法的方法。它对字段(甚至是公共字段)没有同样的作用 无论如何,您都不想这样做,因为这会导致较大的扩展问题-如果两个不同的客户端都更改了“msh”的值,该怎么办
您最好将所需的任何状态传递给每个服务方法。我认为没有人能够在不看到您正在调用的web服务的情况下解决此问题。你有它的网址吗?还是文档?谢谢你的回复,科林,但由于一些问题,我无法向你显示URL和文档。但我有一个问题。我可以使用添加服务引用添加普通web服务吗?
Private void Test()
{
SR.Service1 objS=new SR.Service1();
SR.MsgHeader msh=new SR.MsgHeader();
msh.Name="test";
// I have given some more values to msh
objS.msh=msh;
int result= objS.Fun2();
}