简体   繁体   中英

Jmeter - How to send XML request to a server?

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:

<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:

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

Response headers:

HTTPSampleResult fields: ContentType:
DataEncoding: null

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

Is there something else that I am missing here?

Thanks in advance!

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请求

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.

  1. You browser uses proxy to connect to the Internet and JMeter doesn't. Try hitting ie 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:

     -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 (eg *.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 ie telnet command. If telnet is able to connect - JMeter will be able as well as the error states that connection cannot be established.
  3. Make sure that you use correct HTTP method.
  4. You may also need to pass relevant Content-Type header value eg text/xml or application/soap+xml via HTTP Header Manager

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM