【问题标题】:Namespace is not supported with rpc\\literal SOAP. The wrapper element has to be unqualifiedrpc\\literal SOAP 不支持命名空间。包装器元素必须是不合格的
【发布时间】:2013-08-16 09:12:01
【问题描述】:

我目前正在与一家租赁服务提供商进行集成,该服务提供商运行(我假设)Java 服务。

当我在 Visual Studio 2012 中添加服务引用时,引用已正确创建,我可以调用服务中指定的方法。

当我收到服务的响应时,问题就出现了。

假设我用错误的参数调用服务getCalculation,我得到了JSON 响应JSONException。问题是,Visual Studio 抛出异常 There was an error reflecting 'JSONException'. 和 InnerException: {"Namespace='http://service.ecommerce.cetelem.hu/' is not supported with rpc\\literal SOAP. The wrapper element has to be unqualified."}

这是 web.config 代码:

<system.serviceModel>  
    <bindings>  
        <basicHttpBinding>  
            <binding name="EcommerceServiceImplPortBinding">  
                <security mode="Transport" />  
            </binding>  
            <binding name="EcommerceServiceImplPortBinding1" />  
        </basicHttpBinding>  
    </bindings>  
    <client>  
        <endpoint address="https://ecomdemo.cetelem.hu:443/ecommerce/EcommerceService"
          binding="basicHttpBinding" bindingConfiguration="EcommerceServiceImplPortBinding"
          contract="CetelemInstallmentsService.EcommerceService" name="EcommerceServiceImplPort" />  
    </client>  
</system.serviceModel>

如果这有任何帮助,我将 WebAPI 用于用户“前端”。

谢谢大家的回答!

【问题讨论】:

  • 无法理解这是 json 还是 xml 服务。对于 json - 可能想要使用 web api 或者只是发送原始 json。对于 xml - 您可以通过使用“添加 Web 引用”而不是“添加服务引用”来使用 .net 2 Web 服务
  • 感谢您的评论。问题是,服务是用 WSDL 定义的,但它返回 JSON。

标签: c# .net wcf soap asp.net-web-api


【解决方案1】:

我最终想通了这件事,但在另一篇关于 SO 的帖子的帮助下:SOAP Requests in .net

我只需要在服务引用文件中进行更改:

[System.ServiceModel.XmlSerializerFormatAttribute(Style = System.ServiceModel.OperationFormatStyle.Rpc, SupportFaults = true)]

收件人:

[System.ServiceModel.XmlSerializerFormatAttribute(Style = System.ServiceModel.OperationFormatStyle.Document, SupportFaults = true)]

【讨论】:

  • 服务引用文件名为Reference.cs。
  • 除非选择“显示所有文件”,否则参考文件也会隐藏在 Visual Studio 解决方案资源管理器中
  • 当我这样做时,我无法读取任何返回的响应。
  • @ChrisRice:你解决了这个问题吗?
  • 不,我找到了我认为的替代方案。
猜你喜欢
  • 2017-03-24
  • 2023-03-29
  • 1970-01-01
  • 2014-01-28
  • 1970-01-01
  • 2012-03-03
  • 1970-01-01
  • 2011-06-22
  • 1970-01-01
相关资源
最近更新 更多