我正在尝试制作Xamarin应用程序,它将通过WCF通过WSDL处理Web服务。 我有.wsdl文件和.cs文件由SvcUtil使用.wsdl文件生成。
当我做下一个时:
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上运行?
提前致谢。
答案 0 :(得分:0)
不幸的是Mono还不支持BasicHttpSecurityMode.TransportWithMessageCredential,你可能想要使用 BasicHttpSecurityMode.Transport目前。
参考:http://forums.xamarin.com/discussion/comment/44741/#Comment_44741