【问题标题】:How to send a Soap Request in JMeter to a WCF Service - Getting Bad Request 400 Error如何在 JMeter 中将 Soap 请求发送到 WCF 服务 - 出现错误请求 400 错误
【发布时间】:2015-11-30 12:51:24
【问题描述】:

我有以下 WCF 服务操作:

[ServiceContract(ConfigurationName="IDocumentGenerator")]
    public interface IDocumentGenerator
    {
        [OperationContract(Action = "GenerateDocument")]
        XmlDocument GenerateDocument(int TemplateId, string Format, XmlDocument Payload);
    }

我可以通过导航到服务在浏览器中加载 WSDL。但是,当我在 Jmeter 中向同一个服务发送“SOAP/XML-RPC 请求”时,我收到了响应代码 - 400 - 错误请求。

以下是我正在使用的 Soap 消息:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <GenerateDocument>
            <Format>Pdf</Format>
            <TemplateId>6</TemplateId>
            <Payload><a></a></Payload>
        </GenerateDocument>     
    </soapenv:Body>
</soapenv:Envelope>

【问题讨论】:

    标签: xml web-services wcf soap wsdl


    【解决方案1】:

    WCF 将不支持 XmlDocument 直接作为 Operation 参数。您需要在 OperationContract 属性中使用 XmlSerializerFormat:

    [OperationContract(Action = "GenerateDocument"), XmlSerializerFormat]
    

    我创建的 Soap 请求也无效。要创建 Soap 请求,我们可以使用来自http://www.soapui.org/ 的软件。创建有效的 Soap 请求后,我能够解决问题:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
       <soapenv:Header/>
       <soapenv:Body>
          <tem:GenerateDocument>
             <tem:TemplateId>2</tem:TemplateId><tem:Format>2</tem:Format>
             <!--Optional:-->
    
             <!--Optional:-->
             <tem:Payload>
                <a/>
             </tem:Payload>
          </tem:GenerateDocument>
       </soapenv:Body>
    </soapenv:Envelope>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-10
      • 1970-01-01
      • 2012-04-27
      • 2015-11-24
      • 2011-09-29
      • 2014-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多