Jmeter - 如何向服务器发送 XML 请求?

Jmeter - How to send XML request to a server?

我的测试计划中有一个 HTTP 请求采样器。我已经提供了我的服务器名称或 IP、端口和 url。我选择了 Body Data 选项卡并以这种方式提出了 XML 请求:

<Request>
    <Header><Log><Level>None</Level></Log></Header>
    <Body>
        <Action>
            <GetService>
                <Code>ABC</Code>
                <CodeValue>XYZ</CodeValue>
            </GetService>
        </Action>
    </Body> </Request>

然而,这就是我得到的以下采样器结果:

Response code: Non HTTP response code: java.net.ConnectException Response message: Non HTTP response message: Connection refused

Response headers:

HTTPSampleResult fields: ContentType:
DataEncoding: null

我已经确定我可以 ping 我的服务器。它起来 运行。

我还遗漏了什么吗?

提前致谢!

我发现使用 SOAP/XML-RPC 请求这种东西最简单。只需输入您要发送的 XML 和 URL 并确保未选中发送 SOAPAction(如果您不使用它)。

您遇到的问题似乎与此无关。看起来 JMeter 无法连接到服务器。您应该使用浏览器手动尝试,然后转到您要将 XML 发送到的 URL。你至少应该得到一个 400 错误。 "Connection Refused" 看起来更像是服务器不是 运行。

  1. 您的浏览器使用代理连接到 Internet,而 JMeter 没有。尝试通过以下命令行参数点击 http://example.com domain with a single JMeter GET request and if it fails - configure JMeter to use the same proxy as browser does

    -H, --proxyHost <argument>
           Set a proxy server for JMeter to use
    -P, --proxyPort <argument>
           Set proxy server port for JMeter to use
    -N, --nonProxyHosts <argument>
           Set nonproxy host list (e.g. *.apache.org|localhost)
    -u, --username <argument>
           Set username for proxy server that JMeter is to use
    -a, --password <argument>
           Set password for proxy server that JMeter is to use 
    
  2. 仔细检查您的 Server NamePort 值并通过 telnet 命令验证它们。如果 telnet 能够连接 - JMeter 将能够以及无法建立连接的错误状态。
  3. 确保您使用正确的 HTTP 方法。
  4. 您可能还需要通过相关的 Content-Type header value e.g. text/xml or application/soap+xml via HTTP Header Manager