服务参考未创建方法 [英] Service reference is not creating methods

查看:53
本文介绍了服务参考未创建方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将对SOAP Web服务的服务引用添加到我的ASP.NET MVC应用程序中,以便能够从此处使用Web服务.

I'm trying to add a service reference to a SOAP web service into my ASP.NET MVC application so I'm able to consume the web service from here.

问题在于,服务引用没有创建我可以从常规应用程序中使用的任何类或方法,它仅定义了两个接口和许多数据类型.

The problem is, that the service reference isn't creating any class or method I can use from my regular app, it's only defining two interfaces and a lot of data types.

也许我弄错了,但是据我了解,服务引用应该创建一个类,我可以使用该类来调用服务上的不同方法.然后,我的工作就是将业务模型数据转换为Web服务的数据类型,以便我可以将参数发送给方法并使用它们的响应.

Maybe I'm mistaken, but as I'm understanding it, the service reference should create a class that I'd be able to use to call the different methods on the service. Then is my job to translate my business model data to the data types of the web service so I can send parameters to methods and work with their responses.

我做错了吗,应该使用其他方法来使用外部SOAP Web服务吗?

Am I doing it wrong and should use a different approach to consume external SOAP web services?

推荐答案

检查您的服务参考.右键单击并单击配置服务参考".取消选中在引用的程序集中重用类型",然后让它重建代理.

Check your Service Reference. Right-click and "Configure Service Reference". Uncheck "Reuse types in referenced assemblies" and let it rebuild the proxies.

就我而言,我创建了对WCF服务的服务引用",称为示例".这将创建一个名称空间 WebApplication1.Example .

In my case I created a Service Reference to my WCF service called "Example". This creates a namespace WebApplication1.Example.

我的WCF服务简称为 Service1 ,它是 IService1 的实现,它具有2个默认操作以及我添加的 Add 有趣.

My WCF service is simply called Service1 which is an implementation of IService1, which has the 2 default operations and an Add that I added for funsies.

一旦有了Service Reference,我就有一个使用WebApplication1.Example; 的,然后在C#中, var client = new Service1Client(); .请注意,约定是在我的服务名称后附加"-Client",这很有意义,因为它是实际服务的代理.

Once the Service Reference is there, I have a using WebApplication1.Example; and then in C#, var client = new Service1Client();. Note that the convention appends "-Client" to my service name, which makes sense, as it's a proxy to the actual service.

从那里开始只是 var x = client.Add(5,6);

顺便说一句,您可能不需要Web参考.尽管它可能起作用",但它与Service Reference甚至还不一样.网络参考与服务参考

BTW, you may not want a Web Reference. While it may "just work", it's not even close to being the same thing as a Service Reference. Web Reference vs. Service Reference

HTH!

这篇关于服务参考未创建方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆