通用 Windows 平台 - 使用 Web 服务,ASMX(内容类型解析) [英] Universal windows platform - Consuming web service, ASMX (Content type parsing)

查看:30
本文介绍了通用 Windows 平台 - 使用 Web 服务,ASMX(内容类型解析)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始使用 UWP,并希望使用用 VB.Net 2.0 编写的旧的、经常使用的 ASMX Web 服务.

I'm getting started with UWP and wish to consume an old, heavily used ASMX web service written in VB.Net 2.0.

我已经创建了一个对 Web 服务的服务引用,但是无论我调用什么函数,我总是以错误告终

I have created a service reference to the web service but whatever function I call I always end up with the error

mscorlib.ni.dll 中发生了System.PlatformNotSupportedException"类型的异常,但未在用户代码中处理

"An exception of type 'System.PlatformNotSupportedException' occurred in mscorlib.ni.dll but was not handled in user code

附加信息:不支持 MessageEncoder 内容类型解析."

Additional information: MessageEncoder content type parsing is not supported."

没有比这更进一步的帮助了,不确定是不是因为返回类型是 XML 并且它需要 JSON 或其他东西,即使是这种情况,我也看不到任何地方可以改变它.

There's no further help than this, not sure if it's because the return type is XML and it's expecting JSON or something, even if that were the case I see nowhere to change this.

这是我用来撤回简单响应的相关行,不胜感激.

Here is the relevant lines that I am using to pull back a simple response, help would be greatly appreciated.

WSSoapClient proxy = new WSSoapClient();
Guid ProviderGUID = Guid.Parse("[REDACTED]");
string ProviderPassword = "[REDACTED]";
objWSEthnicitiesGetReturn result;
result = await proxy.WSEthnicitiesGetAsync(ProviderGUID, ProviderPassword);

推荐答案

我发现了这个问题,而 W/S 正在使用 HTTP...在使用期间,端点已更改为 HTTP.现在,虽然 IIS 中存在重定向,但这会导致查找始终返回 301 错误.

I found the issue, while the W/S is using HTTP... during use the endpoint was changed to HTTP. Now while there is a redirect in IIS this caused the lookup to always return a 301 error.

在服务参考的参考文件中,我必须更改 proc GetBindingForEndpoint 以包含以下几行

In the reference file for the Service Reference I had to alter the proc GetBindingForEndpoint to include the following lines

result.Security.Transport.ClientCredentialType = System.ServiceModel.HttpClientCredentialType.None;
result.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;

在将引用引入项目的同时,.NET 还将对 HTTPS 的所有引用更改为 HTTP,因此我必须搜索整个项目中的所有实例并手动将它们全部更改.

Whilst bringing the reference into the project .NET had also changed all references to the HTTPS to HTTP so I had to do a search for all instances throughout the project and manually change them all.

现在一切都很好,所以感谢你们的时间.

All is good now though so thank you for your time guys.

这篇关于通用 Windows 平台 - 使用 Web 服务,ASMX(内容类型解析)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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