简体   繁体   English

wsdl到asmx webservice帮助!

[英]wsdl to asmx webservice HELP!

I've searched for this problem and I always get stuck on the step after you've generated a .cs file using the command "wsdl.exe myfile.wsdl /l:CS /ServerInterface" in the Microsoft Visual Studio prompt. 我已经搜索了此问题,并且在Microsoft Visual Studio提示符下使用命令“ wsdl.exe myfile.wsdl / l:CS / ServerInterface”生成.cs文件后,始终会卡在该步骤上。 I've imported the .cs file into a Visual Studio web service project. 我已将.cs文件导入到Visual Studio Web服务项目中。 and It have a service1.asmx.cs file I dont know what to do with. 并且它有一个service1.asmx.cs文件,我不知道该怎么办。

I'm a complete newbie when it comes to .NET, C#, Visual Studio and Web Service so a step to step guide would be awesome! 当涉及.NET,C#,Visual Studio和Web Service时,我是一个完全的新手,因此一步一步的指导非常棒!

Forgo the command-line wsdl.exe utility - it's much easier in Visual Studio itself. 放弃命令行wsdl.exe实用程序-在Visual Studio本身中要容易得多。 If you're using VS 2008 or later, right-click on your project, select Add Service Reference and point it to the WSDL on the server you'll be connecting to (eg http://www.blahblah.com/service.asmx?WSDL ) and it will generate the proxy classes and connection parameters in an app.config file. 如果您使用的是VS 2008或更高版本,请右键单击您的项目,选择“添加服务引用”,然后将其指向要连接到的服务器上的WSDL(例如 http://www.blahblah.com/service)。 asmx?WSDL ),它将在app.config文件中生成代理类和连接参数。

From where you are, instantiate an object of the proxy class it generated (make sure the namespace it generated is included with a using statement) and make sure it is bound to an endpoint: 从您所在的位置实例化其生成的代理类的对象(确保其生成的名称空间包含在using语句中),并确保将其绑定到端点:

BasicHttpBinding binding =
    new BasicHttpBinding(BasicHttpSecurityMode.None);
binding.MaxReceivedMessageSize = int.MaxValue;
EndpointAddress address =
    new EndpointAddress("http://webservices.blahblah.com/service.asmx");
MyService service = new MyServiceClient(binding, address);

and then invoke the remote methods on it: 然后在其上调用远程方法:

try
{
    service.DoSomething("someParameter");
    if (service.GetSomeStatus())
    {
    }
}
finally
{
    (service as IDisposable).Dispose();
}

For VS 2005 or earlier, use Add Web Reference and the rest of the procedure is similar. 对于VS 2005或更早版本,请使用“添加Web参考”,其余过程类似。

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

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