【问题标题】:WCF service reference generates void methods from WSDLWCF 服务引用从 WSDL 生成 void 方法
【发布时间】:2011-04-16 21:42:19
【问题描述】:

这是我第一次尝试使用 WCF,所以我猜我做错了。 我正在尝试访问由http://confluence.atlassian.com/rpc/soap-axis/confluenceservice-v1?wsdl 的WSDL 定义的soap 服务我正在使用VS2010,我向我的项目添加了一个服务引用并将其指向那里的URL(或者更确切地说,我们的Intranet 安装它),但是当我使用对象浏览器查看服务时,界面上的操作都是不带参数的空方法。似乎 WCF 没有正确读取类型信息。它不会给出错误,但会发出大量警告,如下所示:

警告 1 自定义工具警告:故障 在命名为 InvalidSessionException 操作 getPermissions 不能 进口的。不支持的 WSDL,故障 消息部分必须引用 元素。此故障信息不 引用一个元素。如果你有编辑 访问 WSDL 文档,您可以 通过引用来解决问题 使用“元素”的架构元素 属性。 Z:\TestLibrary\Service References\Confluence\Reference.svcmap 1 1 TestLibrary

警告 2 自定义工具警告: 可选的 WSDL 扩展元素 'body' 从命名空间 'http://schemas.xmlsoap.org/wsdl/soap/' 没有被处理。 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 中使用了哪些类型并自己创建类和数据协定,还是其他?

【问题讨论】:

    标签: c# wcf web-services visual-studio-2010


    【解决方案1】:

    刚刚在 JIRA 4.4 上遇到了这个问题,如果您使用较旧的 Web 参考而不是服务参考,它确实可以工作。

    有关执行此操作的说明,请参阅:Web Reference vs. Service Reference

    这对我来说是最简单的解决方案,因为我知道 JIRA 正在转向 REST(远离 SOAP),而我只是想快速启动和运行。

    【讨论】:

      【解决方案2】:

      嗯...有趣 - 我从命令行针对您提供的 URL 运行了 svcutil.exe,虽然我收到了大量关于 WSDL 问题的警告,但我也收到了一些代码 - 类似:

      //------------------------------------------------------------------------------
      // <auto-generated>
      //     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.
      // </auto-generated>
      //------------------------------------------------------------------------------
      
      [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 服务对话。

      【讨论】:

      • 嗯...它似乎正在使用 svcutil.exe。这真的很奇怪。不过还是谢谢。
      • 也对我有用,如果你在 Visual Studio 开始菜单下有一个 VS 命令提示符的快捷方式,可以让 svcutil 易于访问,然后:svcutil.exe http://somedomain.com/someapi.wsdl
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多