简体   繁体   English

Xamarin表单,使用WCF服务错误

[英]Xamarin Forms, using WCF Service Error

Currently I have Xamarin.Forms application which use service reference WCF, SellerCloud API which is on " http://ws.timezone123.com/SCService.asmx ". 当前,我有Xamarin.Forms应用程序,该应用程序使用服务引用WCF和“ http://ws.timezone123.com/SCService.asmx ”上的SellerCloud API。

Referencing SCService I receive two compile exceptions "The type or namespace name 'XmlElement' does not exist in the namespace 'System.Xml' (are you missing an assembly reference?)" and "The type or namespace name 'schema' could not be found (are you missing a using directive or an assembly reference?)". 引用SCService时,我收到两个编译异常:“名称空间'System.Xml'中不存在类型或名称空间名称'XmlElement'(是否缺少程序集引用?)”和“不能使用类型或名称空间名称'schema'找到(您是否缺少using指令或程序集引用?)”。

http://prntscr.com/g5sgf1 http://prntscr.com/g5sgf1

Currently library, from which I am trying to reference service is Portal Class Library with Target Framework "Profile7". 我正在尝试从中引用服务的当前库是具有目标框架“ Profile7”的门户网站类库。

Can you suggest what I can do in that case to make it work? 您能建议我在这种情况下可以做些什么吗?

Thanks 谢谢

How did you add the service reference to PCL? 您如何将服务参考添加到PCL?

You are trying to consume ASMX web service( XML web service with SOAP protocol). 您正在尝试使用ASMX Web服务(带有SOAP协议的XML Web服务)。 As i can see your screenshot ,you added a connected service (typically used for azure app services) not a Web reference . 正如我看到的屏幕快照所示,您添加了一个连接的服务(通常用于azure应用程序服务)而不是Web参考 In order to consume ASMX service you need to add a Web reference . 为了使用ASMX服务,您需要添加一个Web参考

Problem is, web reference is not available in PCL .But it is available in platform specific projects(right click the droid or Ios project --->Add--->Web Reference). 问题是,PCL中没有Web参考,但平台特定项目中有Web参考(右键单击droid或Ios项目---> Add ---> Web参考)。

If you add web reference correctly it will generate proxies within your platform specif projects.Then you need to access generated web methods through Dependency service in your PCL.Please check following documentation for further idea 如果正确添加Web参考,它将在您的平台规范项目中生成代理。然后您需要通过PCL中的Dependency服务访问生成的Web方法。请查看以下文档以获取进一步的想法

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/#asmx https://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/#asmx

Following question is some what similar to your problem 接下来的问题与您的问题有些相似

Is there any supported way to call asmx web services from cross-platform Xamarin code? 有什么受支持的方法可以从跨平台Xamarin代码调用asmx Web服务?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM