JMeter-无法通过POST变量发送HTTP请求吗? [英] JMeter - Trouble sending HTTP request with POST variable?
问题描述
我正在尝试对从存档数据库中获取记录的Java servlet进行负载测试.
I am trying to load test a java servlet that fetches records from an archive database.
该servlet的工作方式如下:
The servlet works as follows:
- 1-从HTTP标头中读取post变量
- 2-使用变量查询数据库
- 3-返回XML
我已经设置了一个测试,该测试要通过post变量触发HTTP请求,但是该测试无法正常工作,并且会出现J Meter错误.
I have setup a test which I want to fire off HTTP requests with post variables however the test is not working, getting errors with J Meter.
屏幕截图1-显示测试的结构
截屏2-显示我正在读取的CSV文件
我已将CSV文件放置在与保存测试计划相同的文件夹中!
I have placed the CSV file in the same folder that my test plan is saved in!
截屏3-显示HTTP请求
这是错误输出:
线程名称:线程组1-1示例开始时间:2012-11-20 10:35:27 GMT 加载时间:0延迟:0以字节为单位的大小:1113标头以字节为单位的大小:0 正文大小(以字节为单位):1113样本计数:1错误计数:1响应代码: 非HTTP响应代码:java.net.URISyntaxException响应消息: 非HTTP响应消息:IPv6地址的预期右括号 在索引13: http://[http://sophos1.testserver.co .uk/servlet/archive]:61061/
Thread Name: Thread Group 1-1 Sample Start: 2012-11-20 10:35:27 GMT Load time: 0 Latency: 0 Size in bytes: 1113 Headers size in bytes: 0 Body size in bytes: 1113 Sample Count: 1 Error Count: 1 Response code: Non HTTP response code: java.net.URISyntaxException Response message: Non HTTP response message: Expected closing bracket for IPv6 address at index 13: http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/
响应头:
HTTPSampleResult字段:ContentType:DataEncoding:空
HTTPSampleResult fields: ContentType: DataEncoding: null
POST请求
POST http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/
POST data:
[no cookies]
返回的数据
java.net.URISyntaxException: Expected closing bracket for IPv6 address at index 13: http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/
at java.net.URI$Parser.fail(Unknown Source)
at java.net.URI$Parser.failExpecting(Unknown Source)
at java.net.URI$Parser.parseServer(Unknown Source)
at java.net.URI$Parser.parseAuthority(Unknown Source)
at java.net.URI$Parser.parseHierarchical(Unknown Source)
at java.net.URI$Parser.parse(Unknown Source)
at java.net.URI.<init>(Unknown Source)
at java.net.URL.toURI(Unknown Source)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:232)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1075)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1064)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:426)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:255)
at java.lang.Thread.run(Unknown Source)
请帮助!
谢谢
推荐答案
从HTTP Request Sampler的Server Name/IP字段中删除http://
(在HTTP请求字段说明).
Remove http://
from Server Name / IP field of your HTTP Request Sampler (that's pointed in HTTP Request fields description).
在上面的描述中查看您生成的POST请求:
Look onto your generated POST request above in description:
POST Request
POST http://[http://sophos1.testserver.co.uk/servlet/archive]:61061/
将您的HTTP请求配置为以下内容:
Configure your HTTP Request as the following instead:
Server Name: sophos1.testserver.co.uk
Path: /servlet/archive
Implementation: Java
这篇关于JMeter-无法通过POST变量发送HTTP请求吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!