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

时间:2021-11-22 12:44:57

I have a HTTP Request Sampler in my test plan. I have given my server name or IP, port and url. I chose the Body Data tab and gave an XML request in this way:

我的测试计划中有一个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>

However, this what I am getting back the following as the Sampler result:

但是,这就是我取回以下作为Sampler结果:

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

响应代码:非HTTP响应代码:java.net.ConnectException响应消息:非HTTP响应消息:连接被拒绝

Response headers:

HTTPSampleResult fields: ContentType:
DataEncoding: null

HTTPSampleResult字段:ContentType:DataEncoding:null

I have made sure that I can ping my server. Its up and running.

我已经确定我可以ping我的服务器了。它正常运行。

Is there something else that I am missing here?

我还缺少其他的东西吗?

Thanks in advance!

提前致谢!

2 个解决方案

#1


I find it the easiest to just use a SOAP/XML-RPC Request for this kind of stuff. Simply enter the XML you want to send and the URL and make sure that Send SOAPAction is unchecked if you're not using it.

我觉得最简单的方法就是使用SOAP / XML-RPC请求这类东西。只需输入您要发送的XML和URL,并确保如果您不使用它,则取消选中Send SOAPAction。

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

The problem you're having seems to be unrelated though. It looks like JMeter can't get a connection to the server. You should try it manually by using your browser and going to the URL you want to send the XML to. You should at least get a 400 error. "Connection Refused" looks more like the server isn't running.

你遇到的问题似乎无关紧要。看起来JMeter无法连接到服务器。您应该使用浏览器手动尝试并转到要将XML发送到的URL。你应该至少得到400错误。 “拒绝连接”看起来更像是服务器没有运行。

#2


  1. You browser uses proxy to connect to the Internet and JMeter doesn't. Try hitting i.e. http://example.com domain with a single JMeter GET request and if it fails - configure JMeter to use the same proxy as browser does via the following command-line parameters:

    您的浏览器使用代理连接到Internet,而JMeter则不使用。尝试使用单个JMeter GET请求命中http://example.com域,如果失败,请通过以下命令行参数将JMeter配置为使用与浏览器相同的代理:

    -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. Double check your Server Name and Port values and validate them via i.e. telnet command. If telnet is able to connect - JMeter will be able as well as the error states that connection cannot be established.
  3. 仔细检查您的服务器名称和端口值,并通过ie telnet命令验证它们。如果telnet能够连接 - JMeter将能够以及错误状态表明无法建立连接。

  4. Make sure that you use correct HTTP method.
  5. 确保使用正确的HTTP方法。

  6. You may also need to pass relevant Content-Type header value e.g. text/xml or application/soap+xml via HTTP Header Manager
  7. 您可能还需要传递相关的Content-Type标头值,例如通过HTTP标头管理器发送text / xml或application / soap + xml

#1


I find it the easiest to just use a SOAP/XML-RPC Request for this kind of stuff. Simply enter the XML you want to send and the URL and make sure that Send SOAPAction is unchecked if you're not using it.

我觉得最简单的方法就是使用SOAP / XML-RPC请求这类东西。只需输入您要发送的XML和URL,并确保如果您不使用它,则取消选中Send SOAPAction。

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

The problem you're having seems to be unrelated though. It looks like JMeter can't get a connection to the server. You should try it manually by using your browser and going to the URL you want to send the XML to. You should at least get a 400 error. "Connection Refused" looks more like the server isn't running.

你遇到的问题似乎无关紧要。看起来JMeter无法连接到服务器。您应该使用浏览器手动尝试并转到要将XML发送到的URL。你应该至少得到400错误。 “拒绝连接”看起来更像是服务器没有运行。

#2


  1. You browser uses proxy to connect to the Internet and JMeter doesn't. Try hitting i.e. http://example.com domain with a single JMeter GET request and if it fails - configure JMeter to use the same proxy as browser does via the following command-line parameters:

    您的浏览器使用代理连接到Internet,而JMeter则不使用。尝试使用单个JMeter GET请求命中http://example.com域,如果失败,请通过以下命令行参数将JMeter配置为使用与浏览器相同的代理:

    -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. Double check your Server Name and Port values and validate them via i.e. telnet command. If telnet is able to connect - JMeter will be able as well as the error states that connection cannot be established.
  3. 仔细检查您的服务器名称和端口值,并通过ie telnet命令验证它们。如果telnet能够连接 - JMeter将能够以及错误状态表明无法建立连接。

  4. Make sure that you use correct HTTP method.
  5. 确保使用正确的HTTP方法。

  6. You may also need to pass relevant Content-Type header value e.g. text/xml or application/soap+xml via HTTP Header Manager
  7. 您可能还需要传递相关的Content-Type标头值,例如通过HTTP标头管理器发送text / xml或application / soap + xml