如何在 MVC 中使用我的 Web 参考?
大家好,我需要在我的 MVC 应用程序中引用外部服务。
我正在使用此服务来验证我们的一位客户要求我们使用的身份验证令牌。
我正在将一个旧项目移植到 MVC。 我添加了一个网络参考。
配置是这样生成的:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ExternalServicesSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myapps.test.com/ExternalServices/ExternalServices.asmx"
binding="basicHttpBinding" bindingConfiguration="ExternalServicesSoap"
contract="AssertionService.ExternalServicesSoap" name="ExternalServicesSoap" />
</client>
在旧的 ASP.NET 世界中,我可以使用外部服务引用中定义的 Assertion 对象对我引用的特定服务执行以下操作。
var service = new ExternalServices();
Assertion assertion = service.Validate(Id);
if(assertion.Valid){}
MVC 项目中的情况似乎并非如此。 我似乎正在与 WCF 合作。 我不确定我是否在 MVC 世界中正确地处理了这个问题。
我所需要使用的只是一个 ExternalServiesSoap 接口或 ExternalServicesSoapChannel 接口。 它们都不会像 ASP.Net 世界中那样返回 Assertion 对象。 它们都有 Validate 方法,但返回 ValidateAssertionResponse。 响应对象没有任何有用的属性;只是一个响应体。 Assertion 类仍然可以访问,但似乎没有由任何接口方法返回。
谁能帮助我如何正确使用这些接口之一?
谢谢
greeting folks, I need to reference an external service in my MVC app.
I'm using this service to validate an authentication token that one of our clients has requested we use.
I'm porting an older project to MVC.
I added a web reference.
The config was generated like so:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ExternalServicesSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://myapps.test.com/ExternalServices/ExternalServices.asmx"
binding="basicHttpBinding" bindingConfiguration="ExternalServicesSoap"
contract="AssertionService.ExternalServicesSoap" name="ExternalServicesSoap" />
</client>
In the older ASP.NET world, I could do the following on the specific service I am referencing, using the Assertion object defined in the external service reference.
var service = new ExternalServices();
Assertion assertion = service.Validate(Id);
if(assertion.Valid){}
This doesn't seem to be the exact case in the MVC project.
I seem to be working with WCF.
I'm not sure if I'm approaching this properly in the MVC world.
All I have to work with is an ExternalServiesSoap interface or an ExternalServicesSoapChannel interface.
None of which return an Assertion object like in the ASP.Net world.
They both have the Validate method but return a ValidateAssertionResponse.
The response object doesn't have any useful properties; just a response body.
The Assertion class is still accessible but it doesn't seem to be returned by any of the interface methods.
Can anyone help me with how to properly use one of these interfaces?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加 Web 引用,而不是添加服务引用。右键单击您的项目,选择“添加服务引用...”。在“添加服务引用”对话框中,单击“高级”,然后单击“添加 Web 引用”。这将生成一个适合与基于 ASMX 的服务一起使用的代理。
Rather than adding a Service Reference, add a Web Reference. Right click on your project, select "Add Service Reference...". In the Add Service Reference dialog, click "Advanced", then click "Add Web Reference". This will generate a proxy that is appropriate for use with ASMX based services.