Xamarin Forms 添加的 Web 服务无法正常工作
我通过 WCF 添加了一个连接服务到我的 Xamarin.Forms 项目,然后添加了这些代码:
private async void NumberToWord(ulong num)
{
NumConvert.NumberConversionSoapTypeClient client = new NumConvert.NumberConversionSoapTypeClient(NumConvert.NumberConversionSoapTypeClient.EndpointConfiguration.NumberConversionSoap12);
var result = await client.NumberToWordsAsync(num);
labell.Text = result.ToString();
}
但是当我调用这个函数时,它给出了如下错误:
System.Xml.XmlException:未找到命名空间名称为“http://www.dataaccess.com/webservicesserver/”的“元素“NumberToWordsAsyncResponse”。第 4 行,位置 6。'
I added a connection service to my Xamarin.Forms project via WCF, then added these codes:
private async void NumberToWord(ulong num)
{
NumConvert.NumberConversionSoapTypeClient client = new NumConvert.NumberConversionSoapTypeClient(NumConvert.NumberConversionSoapTypeClient.EndpointConfiguration.NumberConversionSoap12);
var result = await client.NumberToWordsAsync(num);
labell.Text = result.ToString();
}
But when I called this function it gives an error like this:
System.Xml.XmlException: 'Element 'NumberToWordsAsyncResponse' with namespace name 'http://www.dataaccess.com/webservicesserver/' was not found. Line 4, position 6.'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在添加 Web 服务引用时解决了问题,选中了指定客户端选项部分的“生成同步操作”复选框:
在此处输入图片描述:
有了这个,您不仅需要使用异步函数,还需要使用同步函数,这就是我解决问题的方法。
I solved the problem while adding web service referance, checked the "Generate Synchronous Operations" checkbox on specifying the client options section:
enter image description here:
With this you don't need to use only asynchronous functions but also synchronous ones too which is how i solved my problem.