【发布时间】:2023-03-14 08:34:01
【问题描述】:
我正在尝试制作 Xamarin 应用程序,它将通过 WCF over WSDL 使用 Web 服务。 我有 SvcUtil 使用 .wsdl 文件生成的 .wsdl 文件和 .cs 文件。
当我下一步做时:
ServiceClient _mobileService;
public void Initialize()
{
var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential)
{
MaxReceivedMessageSize = long.MaxValue,
MaxBufferSize = int.MaxValue,
MaxBufferPoolSize = long.MaxValue,
ReceiveTimeout = TimeSpan.FromMinutes(0.5),
SendTimeout = TimeSpan.FromMinutes(0.5),
OpenTimeout = TimeSpan.FromMinutes(0.5),
CloseTimeout = TimeSpan.FromMinutes(0.5),
ReaderQuotas =
{
MaxArrayLength = int.MaxValue,
MaxBytesPerRead = int.MaxValue,
MaxDepth = int.MaxValue,
MaxNameTableCharCount = int.MaxValue,
MaxStringContentLength = int.MaxValue
},
Security = {Mode = BasicHttpSecurityMode.Transport}
};
var endpoint = new EndpointAddress("https://ThereIsMySite/PathToService");
_mobileService = new ServiceClient(binding, endpoint);
_mobileService.InnerChannel.OperationTimeout = TimeSpan.FromMinutes(1);
我遇到了异常:
System.InvalidOperationException: Operation 'activateAsync' contains a message with parameters. Strongly-typed or untyped message can be paired only with strongly-typed, untyped or void message.
at System.ServiceModel.Dispatcher.OperationFormatter.Validate (System.ServiceModel.Description.OperationDescription od, Boolean isRpc, Boolean isEncoded) [0x00000] in <filename unknown>:0
at System.ServiceModel.Dispatcher.OperationFormatter..ctor (System.ServiceModel.Description.OperationDescription od, Boolean isRpc, Boolean isEncoded) [0x00000] in <filename unknown>:0
然后我在控制台项目(.Net 4.5)中尝试了相同的代码,没有错误。
是否知道如何让它在 Xamarin 上运行?
提前致谢。
【问题讨论】:
标签: c# web-services wcf wsdl xamarin