Universal windows platform - Consuming web service, ASMX (Content type parsing)

北慕城南 提交于 2019-12-12 02:43:51

问题


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

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

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

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

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);

回答1:


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.

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;

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.



来源:https://stackoverflow.com/questions/40743255/universal-windows-platform-consuming-web-service-asmx-content-type-parsing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!