WCF服务引用从WSDL生成void方法
这是我第一次尝试使用WCF,所以我猜我做错了。 我正在尝试访问由WSDL定义的SOAP服务http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1?wsdl我正在使用VS2010,我在项目中添加了一个服务引用并将其指向那里的URL(或者更确切地说,我们的内部网安装),但是当我使用对象浏览器查看服务时,接口上的操作是没有参数的所有void方法。 似乎WCF没有正确读取类型信息。 它没有给出错误,但它提供了大量的警告,如下所示:
警告1自定义工具警告:操作中名为InvalidSessionException的故障无法导入getPermissions。 不支持的WSDL,故障消息部分必须引用一个元素。 此错误消息不引用元素。 如果您具有对WSDL文档的编辑权限,则可以通过使用“element”属性引用schema元素来解决问题。 Z:\ TestLibrary \ Service References \ Confluence \ Reference.svcmap 1 1 TestLibrary
警告2自定义工具警告:未处理命名空间“ http://schemas.xmlsoap.org/wsdl/soap/ ”中的可选WSDL扩展元素“body”。 XPath:// wsdl:definitions [@ targetNamespace =’ http ://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1′] / wsdl:binding [@ name =’confluenceservice-v1SoapBinding’] / wsdl: operation [@ name =’getPermissions’] / wsdl:input [@ name =’getPermissionsRequest’] Z:\ TestLibrary \ Service References \ Confluence \ Reference.svcmap 1 1 TestLibrary
我究竟做错了什么? 我尝试使用组合选项更改服务的配置,但我永远无法正确地从WSDL中提取类型。 我一直在假设WCF会自动生成类型类以及服务接口。 我是否应该弄清楚WSDL中正在使用哪些类型并自己创建类和数据合同,还是其他什么?
嗯…有趣的是 – 我从命令行对你提供的URL运行svcutil.exe
,虽然我收到大量有关WSDL问题的警告,但我也得到了一些代码 – 类似于:
//------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:2.0.50727.4952 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")] [System.ServiceModel.ServiceContractAttribute(Namespace="http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1", ConfigurationName="ConfluenceSoapService")] public interface ConfluenceSoapService { // CODEGEN: Generating message contract since the wrapper namespace (http://soap.rpc.confluence.atlassian.com) of message getPermissionsRequest does not match the default value (http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1) [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] [System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, Use=System.ServiceModel.OperationFormatUse.Encoded)] getPermissionsResponse getPermissions(getPermissionsRequest request); // CODEGEN: Generating message contract since the wrapper namespace (http://soap.rpc.confluence.atlassian.com) of message searchRequest does not match the default value (http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1) [System.ServiceModel.OperationContractAttribute(Action="", ReplyAction="*")] [System.ServiceModel.XmlSerializerFormatAttribute(Style=System.ServiceModel.OperationFormatStyle.Rpc, Use=System.ServiceModel.OperationFormatUse.Encoded)] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(RemoteException))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(Vector))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(RemotePermission))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(RemoteNodeStatus))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(RemotePageHistory))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(RemoteContentPermission))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(AbstractRemotePageSummary))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(RemoteSpaceSummary))] [System.ServiceModel.ServiceKnownTypeAttribute(typeof(RemoteSearchResult))] searchResponse search(searchRequest request);
所以我会尝试从命令行使用svcutil.exe
来生成ConfluenceSoapService.cs
文件,然后使用它来与您的Confluence服务进行通信。
刚刚在JIRA 4.4上遇到这个问题,如果您使用旧的Web引用而不是服务引用它就可以工作。
有关执行此操作的说明,请参阅: Web引用与服务引用
这对我来说是最简单的解决方案,因为我知道JIRA正在向REST(远离SOAP)发展,我只是想快速启动并运行。
- 调用基于异步任务的WCF方法是否利用I / O完成端口或线程池线程来调用延续?
- 使用C#通过SOA方法进行身份validation
- Wson中的JsonConvert.DeserializeObject和“d”包装器
- 在方法中使用多个参数时,WCF服务代理会引发exception
- entity framework – 基础提供程序在ConnectionString上失败
- Sequence不包含匹配元素 – EntityFramework
- WCF服务参考 – 获取“XmlException:名称不能以'<'字符开头,hex值0x3C”在客户端
- Web服务没有添加引用?
- WCF + Windows Phone 7