我编写了一个http4客户端,将Json数据推送到将接受http请求或发布的服务器。现在,我的代码可以在某些系统上运行,而不能在其他系统上运行?而且我不知道问题出在哪里。是服务器还是客户端。以下是POST到服务器的跟踪以及服务器到客户端的响应。有人可以向我解释为什么这失败了吗?服务器是否告诉我它期望使用JSON以外的东西?谢谢!!!
我尝试使用具有相同结果的不同标题。我尝试发送多部分表单数据媒体类型的CSV文件,但同样失败,并且响应相同? 请注意响应,ACCEPT = multipart / form-data标头 邮政要求
setHeader[CamelHttpMethod, POST] -->
http4://apm-ts-query-svc-prod.app-api.aws-usw02-pr.px.io:443/v2/ts/upload?throwExceptionOnFailure=false <<< Pattern:InOnly,
Headers:{Authorization=Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiI0Zrzfo6VKOA,
breadcrumbId=ID-alfuse2i-35498-1557318510555-3-598, CamelAcceptContentType=application/json, CamelFileAbsolute=false,
CamelFileAbsolutePath=/app/PassThruMT1/jboss-fuse-6.3.0.redhat-310/g-dig/upload/Industries/J402_Motor_2019-05-02-11-00-00_0.csv, CamelFileLastModified=1557319009000, CamelFileLength=1538,
CamelFileName=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileNameConsumed=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileNameOnly=J_Motor_2019-05-02-11-00-00_0.csv, CamelFileNameProduced=g-dig/json/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileParent=g-d/upload/Industries, CamelFilePath=g-dal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileRelativePath=Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelHttpCharacterEncoding=UTF-8,
CamelHttpMethod=POST,
CamelHttpUri=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload?throwExceptionOnFailure=false,
Content-Type=application/json, CUSTKEY=Industries, EXPIRY=2019-05-09 06:36:36.101, TENANT=676f31-752-40d-81-c80c5be, TOKEN=eyJhbGciOiJSUzI1NiIsImtpZeQ2eflqE5C3j44MvhPIR0bSEZgznonA503vrzfo6VKOA, UPLOADURL=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload, x-ge-csvformat=ODB}, BodyType:String, Body:{
"tags" : [ {
"tagId" : "TI5925.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "8.903611",
"q" : "3"
} ]
}, {
"tagId" : "TIA4562.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "56.47153",
"q" : "3"
} ]
}, {
"tagId" : "XIA4596A.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "3.335917",
"q" : "3"
} ]
}, {
"tagId" : "XIA4596B.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "1.670584",
"q" : "3"
} ]
}, {
"tagId" : "TIA4561.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "49.85203",
"q" : "3"
} ]
}, {
"tagId" : "XIA4595A.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "2.098929",
"q" : "3"
} ]
}, {
"tagId" : "XIA4595B.PV",
"data" : [ {
"ts" : "2019-05-02T16:00:00",
"v" : "2.647079",
"q" : "3"
} ]
}, {
"tagId" : "TIA4565.PV",
... [Body clipped after 1000 chars, total length is 16321]
响应
log[HTTP4 Upload Response: ${body}] <<< Pattern:InOnly, Headers:{Accept=multipart/form-data, Authorization=Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiI0ZmYwY2UxZGFhN2E0N2U4ODIwA503vrzfo6VKOA, breadcrumbId=ID-alphprdfuse2i-35498-1557318510555-3-598, Cache-Control=no-cache, no-store, max-age=0, must-revalidate,
CamelAcceptContentType=application/json,
CamelFileAbsolute=false, CamelFileAbsolutePath=/app/PassMT1/jboss-fuse-6.3.0.redhat-310/tal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileLastModified=1557319009000, CamelFileLength=1538,
CamelFileName=Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileNameConsumed=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileNameOnly=J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileNameProduced=g-dal/json/Industries/J_Motor_2019-05-02-11-00-00_0.csv, CamelFileParent=g-dal/upload/Industries,
CamelFilePath=g-dal/upload/Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelFileRelativePath=Industries/J_Motor_2019-05-02-11-00-00_0.csv,
CamelHttpCharacterEncoding=UTF-8, CamelHttpMethod=POST,
CamelHttpResponseCode=415, CamelHttpResponseText=Unsupported Media Type,
CamelHttpUri=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload?throwExceptionOnFailure=false, Connection=keep-alive,
Content-Length=0, Corr=4c4ffcb10fa7ef1c, CUSTKEY=Industries,
Date=Wed, 08 May 2019 12:38:27 GMT, Expires=0, EXPIRY=2019-05-09 06:36:36.101, Pragma=no-cache, Server=none, Strict-Transport-Security=max-age=31536000 ; includeSubDomains, TENANT=67626f31-75-43-81b-cc5bdbce, TOKEN=eyJhbGciOiJSUzI1NiIsI6GlLIGp8-HPeQ2eflqE5C3j44MvhPIR0bSEZgznonA503vrzfo6VKOA, UPLOADURL=https://apm-ts-ingestion-svc-prod.app-api.aws-usw02-pr.px.io/v2/ts/upload, X-Application-Context=APMTS:cloud:0, X-Content-Type-Options=nosniff, X-Frame-Options=DENY, x-ge-csvformat=ODB, X-Vcap-Request-Id=01d04cf7-47ae-4cf9-7d4c-357afe207769, X-Xss-Protection=1; mode=block}, BodyType:org.apache.camel.converter.stream.InputStreamCache, Body:[Body is instance of org.apache.camel.StreamCache]
答案 0 :(得分:0)
好吧,这正是我所怀疑的。事实证明,上传URL具有2个不同的端点,其中/ upload用于CSV数据多部分表单数据,而/ upload不用于JSON。因此,答案是肯定的。服务器正在响应头中发送回预期的媒体类型。
Set::bool(//obj_name);
谢谢,希望这对其他人也有帮助。