I'm trying to call a http-EndPoint with POST method in WSO2 Enterprise Integrator. This EndPoint gets a JSON object as input and return a JSON object as response.
Until now I've used various types of http-EndPoints in Enterprise Integrator without any problem but this particular EndPoint returns an error message which I'm not able to find any clue about it in google.
This is my api:
<resource methods="POST" uri-template="/userInfo">
<inSequence>
<payloadFactory media-type="json">
<format>{"jsonrpc": "2.0", "params": {"auth_type": "ADMIN", "auth_name": "someName", "normal_username": "$1", "auth_pass": "myPassword"},"method": "user.MethodName", "id": 0}
</format>
<args>
<arg evaluator="json" expression="$.user"/>
</args>
</payloadFactory>
<property name="messageType" scope="axis2" type="STRING" value="application/json"/>
<property name="FORCE_HTTP_1.0" scope="axis2" type="STRING" value="true"/>
<send description="">
<endpoint>
<http method="post" uri-template="http://192.168.1.50:1237"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</resource>
This is my error message in console:
[EI-Core] ERROR - TargetHandler HTTP protocol violation : Not a valid protocol version: <head> For : 192.168.1.50:1237
UPDATE
I enabled Wire Logs in WSO2 to investigate in depth about this issue. Here is log output:
[2018-01-15 09:30:46,621] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "POST HTTP/1.0[\r][\n]"
[2018-01-15 09:30:46,622] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Expect: 100-continue[\r][\n]"
[2018-01-15 09:30:46,622] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Content-Type: application/json[\r][\n]"
[2018-01-15 09:30:46,622] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Content-Length: 196[\r][\n]"
[2018-01-15 09:30:46,622] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Host: 192.168.1.50:1237[\r][\n]"
[2018-01-15 09:30:46,622] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Connection: Keep-Alive[\r][\n]"
[2018-01-15 09:30:46,622] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2018-01-15 09:30:46,622] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "[\r][\n]"
[2018-01-15 09:30:46,622] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "{"jsonrpc": "2.0", "params": {"auth_type": "ADMIN", "auth_name": "someName", "normal_username": "myUserName", "auth_pass": "myPassword", "remote_addr": "127.0.0.1"},"method": "user.MethodName", "id": 0}"
[2018-01-15 09:30:46,623] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "<head>[\n]"
[2018-01-15 09:30:46,623] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "<title>Error response</title>[\n]"
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "</head>[\n]"
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "<body>[\n]"
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "<h1>Error response</h1>[\n]"
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "<p>Error code 400.[\n]"
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "<p>Message: Bad HTTP/0.9 request type ('POST').[\n]"
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "<p>Error code explanation: 400 = Bad request syntax or unsupported method.[\n]"
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "</body>[\n]"
Although wire log returned this response: Message: Bad HTTP/0.9 request type ('POST'), but I can send post requests to Endpoint directly without any problem.
Here is direct post request to endpoint:
curl -v -H "Content-Type: application/json" -X POST -d '{"jsonrpc": "2.0", "params": {"auth_type": "ADMIN", "auth_name": "someName", "normal_username": "myUserName", "auth_pass": "myPassword", "remote_addr": "127.0.0.1"}, "method": "user.MethodName", "id": 0}' 192.168.1.50:1237
And here is output result:
STATE: INIT => CONNECT handle 0x600057950; line 1423 (connection #-5000)
Rebuilt URL to: http://192.168.1.50:1237/
Added connection 0. The cache now contains 1 members
Trying 5.202.129.107...
TCP_NODELAY set
STATE: CONNECT => WAITCONNECT handle 0x600057950; line 1475 (connection #0)
Connected to 192.168.1.50 (192.168.1.50) port 1237 (#0)
STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x600057950; line 1592 (connection #0)
Marked for [keep alive]: HTTP default
STATE: SENDPROTOCONNECT => DO handle 0x600057950; line 1610 (connection #0)
POST / HTTP/1.1
Host: http://192.168.1.50:1237
User-Agent: curl/7.56.1
Accept: /
Content-Type: application/json
Content-Length: 197
upload completely sent off: 197 out of 197 bytes
STATE: DO => DO_DONE handle 0x600057950; line 1689 (connection #0)
STATE: DO_DONE => WAITPERFORM handle 0x600057950; line 1814 (connection #0)
STATE: WAITPERFORM => PERFORM handle 0x600057950; line 1824 (connection #0)
HTTP 1.0, assume close after body
Marked for [closure]: HTTP/1.0 close after body < HTTP/1.0 200 OK < Server: BaseHTTP/0.3 Python/2.7.9 < Date: Sun, 14 Jan 2018 07:53:37
GMT < Content-type: application/json < Content-length: 2105 <
STATE: PERFORM => DONE handle 0x600057950; line 1993 (connection #0)
multi_done
Closing connection 0
The cache now contains 0 members
Expire cleared
When I compare headers from WSO2 to headers from curl I cant figure out what are differences. Why WSO2 request failed while curl request succeed?
Try adding this before the <send> mediator.
<property name="FORCE_HTTP_1.0" value="true" scope="axis2"/>
By comparing headers from WSO2 and curl I noticed this line in curl header Rebuilt URL to: http://192.168.1.50:1237/. Hence I changed this:
<endpoint>
<http method="post" uri-template="http://192.168.1.50:1237"/>
</endpoint>
To this:
<endpoint>
<http method="post" uri-template="http://192.168.1.50:1237/"/>
</endpoint>
Add the following properties to the sequence:
FORCE_HTTP_CONTENT_LENGTH
COPY_CONTENT_LENGTH_FROM_INCOMING
This solves the problem, but the reason still unknown.
from your wire log:
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O
dispatcher-1 >> "Message: Bad HTTP/0.9 request type ('POST').[\n]"
[2018-01-15 09:30:46,624] [EI-Core] DEBUG - wire HTTP-Sender I/O
dispatcher-1 >> "Error code explanation: 400 = Bad request syntax
or unsupported method.[\n]" [2018-01-15 09:30:46,624] [EI-Core] DEBUG
- wire HTTP-Sender I/O dispatcher-1 >> "[\n]"
Note: The official HTTP 0.9 specification included only one request method: GET.
you are using post which is not supported in HTTP 0.9
For more information about HTTP 0.9, refer to the original W3C HTTP specification.
Related
We are using c# revit addin in our project.
Design automation requests are getting failed with the error "status": "failedUpload",
Here is the report file for more details
[09/08/2022 17:30:21] Finished running. Process will return: Success
[09/08/2022 17:30:21] ====== Revit finished running: revitcoreconsole ======
[09/08/2022 17:30:25] End Revit Core Engine standard output dump.
[09/08/2022 17:30:25] End script phase.
[09/08/2022 17:30:25] Start upload phase.
[09/08/2022 17:30:25] Uploading 'T:\Aces\Jobs\ad78879202894efba8c5145367e8275d\result.rvt': verb - 'PUT', url - 'https://developer.api.autodesk.com/oss/v2/buckets/generatedmodels/objects/20220908164214_1305 - Interior purged.rvt'
[09/08/2022 17:31:27] Error: Retrying on GatewayTimeout. Request is 'PUT' 'https://developer.api.autodesk.com/oss/v2/buckets/generatedmodels/objects/20220908164214_1305 - Interior purged.rvt'
[09/08/2022 17:32:34] Error: Retrying on GatewayTimeout. Request is 'PUT' 'https://developer.api.autodesk.com/oss/v2/buckets/generatedmodels/objects/20220908164214_1305 - Interior purged.rvt'
[09/08/2022 17:33:51] Error: Retrying on GatewayTimeout. Request is 'PUT' 'https://developer.api.autodesk.com/oss/v2/buckets/generatedmodels/objects/20220908164214_1305 - Interior purged.rvt'
[09/08/2022 17:35:23] Error: Retrying on GatewayTimeout. Request is 'PUT' 'https://developer.api.autodesk.com/oss/v2/buckets/generatedmodels/objects/20220908164214_1305 - Interior purged.rvt'
[09/08/2022 17:35:23] Error: Failed - 504 (GATEWAY_TIMEOUT)
Request: PUT https://developer.api.autodesk.com/oss/v2/buckets/generatedmodels/objects/20220908164214_1305 - Interior purged.rvt
Request Headers:
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IlU3c0dGRldUTzlBekNhSzBqZURRM2dQZXBURVdWN2VhIn0.eyJzY29wZSI6WyJidWNrZXQ6Y3JlYXRlIiwiYnVja2V0OnJlYWQiLCJidWNrZXQ6ZGVsZXRlIiwiZGF0YTpyZWFkIiwiZGF0YTp3cml0ZSIsImRhdGE6Y3JlYXRlIiwiY29kZTphbGwiXSwiY2xpZW50X2lkIjoidFBvVGQ0dENuTEhrajlZMEtRYWRyVFdBT0pLSUxzN1AiLCJhdWQiOiJodHRwczovL2F1dG9kZXNrLmNvbS9hdWQvYWp3dGV4cDYwIiwianRpIjoiU0pnc1N2TjdKTjhFSkhNeFRpdUhmMko2Y3ZTTXhZVW9UZXphcmRJcFNocHZjOWFDM1pzdVVPeDhESjNRc0toViIsImV4cCI6MTY2MjY1ODc0OH0.PJPp7LroxjWkFD7i3_ErLGyM_wS_D0ir1Qr-w9TfHazaEpmZSrwQ6QsRKcJ9ibXS5z9RY_5WGtzojDPyNTF4kP9TISpgJlyJivbLTnxv7oqW_acd0FvQYlvsaozrx_HIfRJIJLLuF_k1gGwpeArK9yQrKtWYSY1_5c3t1QQSEAs4i5HVyWlPPT8eEsQDtY_EYj32QQoeIMnfI3XWWQBkhD1LnbI9yIzLJ0D8ZWzXbbzD78wAhYudzLsW_0ay3YQRd6fTerUVLHaQ0UgyjvFfTVOV5mFZimERqtpyKynIEnF4JBKZGzhzxv-OlEVNe31o5CLr4oy1QBj_E53q5ZX4Ug
Request Content Headers:
Content-Length: 818163712
Response Headers:
Connection: keep-alive
Response Content Headers:
Content-Length: 0
Response Body:
[09/08/2022 17:35:23] Error: Upload failed. Reason = Response status code does not indicate success: 504 (GATEWAY_TIMEOUT).
[09/08/2022 17:35:23] Error: An unexpected error happened during phase Publishing of job.
[09/08/2022 17:35:24] Job finished with result FailedUpload
[09/08/2022 17:35:24] Job Status:
{
"status": "failedUpload",
"reportUrl": "https://dasprod-store.s3.amazonaws.com/workItem/tPoTd4tCnLHkj9Y0KQadrTWAOJKILs7P/ad78879202894efba8c5145367e8275d/report.txt?X-Amz-Expires=48600&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEJj%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIQCgs4MB0vOFtfkJkyouuTSkaG5tzGqnIwaHN41D2ec5IgIgO8%2BddPJXEyQV0NP3R6iKxG7LGccF%2FJtCOZfmDc6oANsqgAMIMBADGgwyMjA0NzMxNTIzMTAiDMhdkXkWdvEoT%2BJc%2FSrdAk0REkrcSRlPtnlJTvPShrpoDhptZ%2FsoZAkNW%2BSWnSY%2FZom%2BNsa2qpmWopbOljmbOcBcmhh2K4JG9dN1AbErLjwd73f3cEId3gQoaE7O1CuBNhzl27K7MQ4tCva%2FxdkYNFV6r0Z%2FdJSylvSYrFyrrTS1jK5da2bL6tXBaJ1GByvRiOlGlDrXFyvNSnp%2FTJT1tJhX6wUGgpUaydqSHGfBsqXR%2Bwzskf8iKLZ7Z75oqCkZwmC9azQARwRT0PoSLTcR4RotaqDDdV8xYqCDUE0Us1ihVMYHKW%2FIrgMiDt5Vb3Cx5YJ68SNbNUAPG5JTmTyG%2BlWQiVXaV3IrH4SWktb494A5CJNJo6CkRmusDEPrvnEfiebWxAUwepcJl%2FU%2FJ8jj7Et1oROuReOS9obYtNHlodcEIOuaG62bsgw53awHzz095z9FV9ZNbStdmqb032uJmiSBWfaPr%2F8Zz7oSiykwpZDomAY6ngF5QHnzayjkxc04F41tGu31CD6DyAhmHq6XVZIUa3hwer76cIjHaZFSM1hWlrCwUUfGesfXXVI81KJrqaqyXkUkUshGBD2tEtvvyYb1CnYvnVssn28Rc0LNNl8WgFwPlfrPutbxT5yRsYTD1aAD2B80wHwBJ7vNLNUnonRMWUzY8QW%2BTO9F8pzb%2FGjLqQTlj3Ne4SM4Fpz8EXIng4gmNA%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIATGVJZKM3BTQV7AHO/20220908/us-east-1/s3/aws4_request&X-Amz-Date=20220908T164217Z&X-Amz-SignedHeaders=host&X-Amz-Signature=f60e89e4fbd1527ba46c42480e64268483c15c5efdcb80ed2623144fbd222317",
"stats": {
"timeQueued": "2022-09-08T16:42:17.9517893Z",
"timeDownloadStarted": "2022-09-08T16:42:18.2481411Z",
"timeInstructionsStarted": "2022-09-08T16:43:20.1483203Z",
"timeInstructionsEnded": "2022-09-08T17:30:25.5436836Z",
"timeUploadEnded": "2022-09-08T17:35:23.6506512Z",
"bytesDownloaded": 1574150920
},
"id": "ad78879202894efba8c5145367e8275d"
}
Please help me to figure out the solution for this problem?
You need to finalize the upload, i.e, after design automation puts file to your s3 bucket you need to call buckets/:bucketKey/objects/:objectKey/signeds3upload
This can be done in OnCallback event, refer https://github.com/Autodesk-Forge/learn.forge.designautomation/blob/7d57b39014de5fccb0f082a9dd50a039bdcb2569/forgesample/Controllers/DesignAutomationController.cs#L456
Refer - https://forge.autodesk.com/en/docs/design-automation/v3/tutorials/revit/step6-prepare-cloud-storage/#step-4-complete-the-upload
I am pushing Lead Details to Salesforce in WSO2 EI. after getting response from Salesforce,facing exception like "forceExpand: error parsing data soruce document for element jsonObject" in aggregation part. Can anyone help me to resolve this?
EI Version: 6.1.1
Request:
{
"getLead":{
"Company":"N/A",
"Email":"mlowery2035#gmail.com",
"FirstName":"Marie",
"PostalCode":"4214",
"Contact__c":"0035500000hcGjcAAE",
"MobilePhone":"+61 410 418 784",
"Model_Name_Text__c":"D90",
"Selling_Dealer__c":"Ferry Rd LDV",
"Lead_Type__c":"Internet",
"LeadSource":"OEM",
"Interest_of_Make_Text__c":"LDV",
"Account__c":"0015500000kkXt7AAE",
"LastName":"Lowery",
"Location__c":"Ferry Rd",
"Department__c":"LDV"
}
}
Response:
"{\"transactionId\":null,\"timestamp\":\"2020-05-12 18:55:41\",\"OpportunityId\":\"0065500000GBt0NAAT\",\"message\":\"Insert/Update success\",\"Le
ad\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AyPLGEA3\"},\"Company\":\"N/A\",\"Email\":\"mlowery2035#gmail.com\",\"FirstName\":\"M
arie\",\"PostalCode\":\"4214\",\"Contact__c\":\"0035500000hcGjcAAE\",\"MobilePhone\":\"+61 410 418 784\",\"Model_Name_Text__c\":\"D90\",\"Interest_Of_Model__c\":\"a0455000009TzvQAA
S\",\"Selling_Dealer__c\":\"Ferry Rd LDV\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"OEM\",\"Interest_of_Make_Text__c\":\"LDV\",\"Account__c\":\"0015500000kkXt7AAE\",\"LastNam
e\":\"Lowery\",\"Location__c\":\"Ferry Rd\",\"Id\":\"00Q5500000AyPLGEA3\",\"Department__c\":\"LDV\"},\"errorCode\":\"200\",\"appraisalId\":null}"
CODE:
<iterate expression="//jsonArray/jsonElement" id="LDVid" sequential="true">
<target>
<sequence>
<!--In this sequence pushed above request to Salesforce -->
<sequence description="VBEmail_LDVNonQualifiedLead_Sequence" key="VBEmail_LDVNonQualifiedLead_Sequence"/>
</sequence>
</target>
</iterate>
<property name="Aggregated_Responses" scope="default">
<jsonObject/>
</property>
<aggregate id="LDVid">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete enclosingElementProperty="Aggregated_Responses" expression="$body/*[1]" xmlns:ns="http://org.apache.synapse/xsd">
<log description="***aggregated***" separator="***aggregated***">
<property expression="$body/*[1]" name="===Aggregated SF Resonse=="/>
</log>
</onComplete>
</aggregate>
axis2 - message Formatter:
<messageFormatter contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamFormatter"/>
Wire Logs:
[2020-05-12 16:17:24,441] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Vary: Accept-Encoding[\r][\n]"
[2020-05-12 16:17:24,441] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
[2020-05-12 16:17:24,442] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "X-XSS-Protection: 1; mode=block[\r][\n]"
[2020-05-12 16:17:24,442] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Content-Type: application/json[\r][\n]"
[2020-05-12 16:17:24,442] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Transfer-Encoding: chunked[\r][\n]"
[2020-05-12 16:17:24,443] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Host: vonbibra--vbdevmerge.my.salesforce.com[\r][\n]"
[2020-05-12 16:17:24,443] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Connection: Keep-Alive[\r][\n]"
[2020-05-12 16:17:24,443] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2020-05-12 16:17:24,443] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "[\r][\n]"
[2020-05-12 16:17:24,444] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "198[\r][\n]"
[2020-05-12 16:17:24,444] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "{"getLead":{"Company":"N/A","Email":"mlowery2035#gmail.com","FirstName":"Marie","PostalCode":"4214","Con
tact__c":"0035500000hcGjcAAE","MobilePhone":"+61 410 418 784","Model_Name_Text__c":"D90","Selling_Dealer__c":"Ferry Rd LDV","Lead_Type__c":"Internet","LeadSource":"OEM","Interest_o
f_Make_Text__c":"LDV","Account__c":"0015500000kkXt7AAE","LastName":"Lowery","Location__c":"Ferry Rd","Department__c":"LDV"}}[\r][\n]"
[2020-05-12 16:17:24,444] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "0[\r][\n]"
[2020-05-12 16:17:24,445] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "[\r][\n]"
[2020-05-12 16:17:29,001] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "HTTP/1.1 200 OK[\r][\n]"
[2020-05-12 16:17:29,001] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Date: Tue, 12 May 2020 10:47:24 GMT[\r][\n]"
[2020-05-12 16:17:29,001] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Strict-Transport-Security: max-age=31536002; includeSubDomains[\r][\n]"
[2020-05-12 16:17:29,001] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Public-Key-Pins-Report-Only: pin-sha256="9n0izTnSRF+W4W4JTq51avSXkWhQB8duS2bxVLfzXsY="; pin-sha256="5kJv
NEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w="; pin-sha256="njN4rRG+22dNXAi+yb8e3UMypgzPUPHlv4+foULwl1g="; max-age=86400; includeSubDomains; report-uri="https://a.forcesslreports.com/hp
kp-report/00D550000000fgkm";[\r][\n]"
[2020-05-12 16:17:29,002] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Expect-CT: max-age=86400, report-uri="https://a.forcesslreports.com/Expect-CT-report/00D550000000fgkm"[\
r][\n]"
[2020-05-12 16:17:29,002] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Content-Type-Options: nosniff[\r][\n]"
[2020-05-12 16:17:29,003] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-XSS-Protection: 1; mode=block[\r][\n]"
[2020-05-12 16:17:29,003] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Robots-Tag: none[\r][\n]"
[2020-05-12 16:17:29,003] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private[\r][\n]"
[2020-05-12 16:17:29,003] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: BrowserId=9yk0npQ9EeqWJksZmFqNqg; domain=.salesforce.com; path=/; expires=Wed, 12-May-2021 1
0:47:24 GMT; Max-Age=31536000[\r][\n]"
[2020-05-12 16:17:29,004] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Type: application/json;charset=UTF-8[\r][\n]"
[2020-05-12 16:17:29,004] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Vary: Accept-Encoding[\r][\n]"
[2020-05-12 16:17:29,004] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Transfer-Encoding: chunked[\r][\n]"
[2020-05-12 16:17:29,005] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
[2020-05-12 16:17:29,005] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "33F[\r][\n]"
[2020-05-12 16:17:29,006] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> ""{\"transactionId\":null,\"timestamp\":\"2020-05-12 20:47:28\",\"OpportunityId\":\"0065500000GBuJsAAL\",
\"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AyPQoEAN\"},\"Company\":\"N/A\",\"Email\":\
"mlowery2035#gmail.com\",\"FirstName\":\"Marie\",\"PostalCode\":\"4214\",\"Contact__c\":\"0035500000hcGjcAAE\",\"MobilePhone\":\"+61 410 418 784\",\"Model_Name_Text__c\":\"D90\",\"
Interest_Of_Model__c\":\"a0455000009TzvQAAS\",\"Selling_Dealer__c\":\"Ferry Rd LDV\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"OEM\",\"Interest_of_Make_Text__c\":\"LDV\",\"Acc
ount__c\":\"0015500000kkXt7AAE\",\"LastName\":\"Lowery\",\"Location__c\":\"Ferry Rd\",\"Id\":\"00Q5500000AyPQoEAN\",\"Department__c\":\"LDV\"},\"errorCode\":\"200\",\"appraisalId\"
:null}""
[2020-05-12 16:17:29,057] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
[2020-05-12 16:17:29,058] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "0[\r][\n]"
[2020-05-12 16:17:29,058] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
[2020-05-12 16:17:29,059] [] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:57e0eec8-fbe3-428a-a127-44291f2a1
aa3, Direction: request, Payload: "{\"transactionId\":null,\"timestamp\":\"2020-05-12 20:47:28\",\"OpportunityId\":\"0065500000GBuJsAAL\",\"message\":\"Insert/Update success\",\"Le
ad\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AyPQoEAN\"},\"Company\":\"N/A\",\"Email\":\"mlowery2035#gmail.com\",\"FirstName\":\"M
arie\",\"PostalCode\":\"4214\",\"Contact__c\":\"0035500000hcGjcAAE\",\"MobilePhone\":\"+61 410 418 784\",\"Model_Name_Text__c\":\"D90\",\"Interest_Of_Model__c\":\"a0455000009TzvQAA
S\",\"Selling_Dealer__c\":\"Ferry Rd LDV\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"OEM\",\"Interest_of_Make_Text__c\":\"LDV\",\"Account__c\":\"0015500000kkXt7AAE\",\"LastNam
e\":\"Lowery\",\"Location__c\":\"Ferry Rd\",\"Id\":\"00Q5500000AyPQoEAN\",\"Department__c\":\"LDV\"},\"errorCode\":\"200\",\"appraisalId\":null}"
[2020-05-12 16:17:29,064] [] ERROR - OMSourcedElementImpl forceExpand: error parsing data soruce document for element jsonObject
javax.xml.stream.XMLStreamException: Not in an object
at org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader.hasNext(AbstractXMLStreamReader.java:449)
at org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader.next(AbstractXMLStreamReader.java:456)
at javax.xml.stream.util.StreamReaderDelegate.next(Unknown Source)
at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:264)
at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getFirstOMChild(OMSourcedElementImpl.java:867)
at org.apache.axiom.om.impl.OMNavigator._getFirstChild(OMNavigator.java:196)
at org.apache.axiom.om.impl.OMNavigator.updateNextNode(OMNavigator.java:140)
at org.apache.axiom.om.impl.OMNavigator.getNext(OMNavigator.java:112)
at org.apache.axiom.om.impl.SwitchingWrapper.updateNextNode(SwitchingWrapper.java:1113)
at org.apache.axiom.om.impl.SwitchingWrapper.<init>(SwitchingWrapper.java:235)
at org.apache.axiom.om.impl.OMStAXWrapper.<init>(OMStAXWrapper.java:74)
at org.apache.axiom.om.impl.llom.OMStAXWrapper.<init>(OMStAXWrapper.java:52)
at org.apache.axiom.om.impl.llom.OMContainerHelper.getXMLStreamReader(OMContainerHelper.java:51)
at org.apache.axiom.om.impl.llom.OMElementImpl.getXMLStreamReader(OMElementImpl.java:736)
at org.apache.axiom.om.impl.llom.OMElementImpl.cloneOMElement(OMElementImpl.java:1038)
at org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:690)
at org.apache.synapse.util.MessageHelper.cloneAxis2MessageContextForAggregate(MessageHelper.java:471)
at org.apache.synapse.util.MessageHelper.cloneMessageContextForAggregateMediator(MessageHelper.java:219)
at org.apache.synapse.mediators.eip.aggregator.AggregateMediator.getAggregatedMessage(AggregateMediator.java:522)
at org.apache.synapse.mediators.eip.aggregator.AggregateMediator.completeAggregate(AggregateMediator.java:456)
at org.apache.synapse.mediators.eip.aggregator.AggregateMediator.mediate(AggregateMediator.java:337)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.filters.SwitchMediator.mediate(SwitchMediator.java:193)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:267)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:775)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:262)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[2020-05-12 16:17:29,081] [] ERROR - AnonymousListMediator Error parsing data source document:Not in an object
java.lang.RuntimeException: Error parsing data source document:Not in an object
at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:269)
at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getFirstOMChild(OMSourcedElementImpl.java:867)
at org.apache.axiom.om.impl.OMNavigator._getFirstChild(OMNavigator.java:196)
at org.apache.axiom.om.impl.OMNavigator.updateNextNode(OMNavigator.java:140)
at org.apache.axiom.om.impl.OMNavigator.getNext(OMNavigator.java:112)
at org.apache.axiom.om.impl.SwitchingWrapper.updateNextNode(SwitchingWrapper.java:1113)
at org.apache.axiom.om.impl.SwitchingWrapper.<init>(SwitchingWrapper.java:235)
at org.apache.axiom.om.impl.OMStAXWrapper.<init>(OMStAXWrapper.java:74)
at org.apache.axiom.om.impl.llom.OMStAXWrapper.<init>(OMStAXWrapper.java:52)
at org.apache.axiom.om.impl.llom.OMContainerHelper.getXMLStreamReader(OMContainerHelper.java:51)
at org.apache.axiom.om.impl.llom.OMElementImpl.getXMLStreamReader(OMElementImpl.java:736)
at org.apache.axiom.om.impl.llom.OMElementImpl.cloneOMElement(OMElementImpl.java:1038)
at org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:690)
at org.apache.synapse.util.MessageHelper.cloneAxis2MessageContextForAggregate(MessageHelper.java:471)
at org.apache.synapse.util.MessageHelper.cloneMessageContextForAggregateMediator(MessageHelper.java:219)
at org.apache.synapse.mediators.eip.aggregator.AggregateMediator.getAggregatedMessage(AggregateMediator.java:522)
at org.apache.synapse.mediators.eip.aggregator.AggregateMediator.completeAggregate(AggregateMediator.java:456)
at org.apache.synapse.mediators.eip.aggregator.AggregateMediator.mediate(AggregateMediator.java:337)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.filters.SwitchMediator.mediate(SwitchMediator.java:193)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:267)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.mediateFromContinuationStateStack(Axis2SynapseEnvironment.java:775)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:282)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:554)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:262)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: Not in an object
at org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader.hasNext(AbstractXMLStreamReader.java:449)
at org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader.next(AbstractXMLStreamReader.java:456)
at javax.xml.stream.util.StreamReaderDelegate.next(Unknown Source)
at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:264)
... 30 more
Note: Tried the same request in soql workbench(Rest Explorer option) which push records to Salesforce successfully.
I am very new to WSO2 development so this could be an easy fix for someone!
I'm creating a demo API to familiarise myself more with WSO2 development. I'm currently stuck with passing a payload in ESB from a back-end (mocked using Wiremock) to another endpoint. I can see in the ESB logs that the payload is coming into ESB but it leaves as 0 or what I presume as empty.
Is there anything extra I should add? I'm just placing a send mediator within a switch statement (checking for HTTP status e.g. 200). I've played around with a payloadFactory but it does the same.
ESB log:
TID: [0] [ESB] [2018-03-28 15:56:48,652] DEBUG {org.apache.synapse.transport.http.wire} - >> "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,652] DEBUG {org.apache.synapse.transport.http.wire} - >> "{"result": 1}" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,699] DEBUG {org.apache.synapse.transport.http.wire} - << "HTTP/1.1 200 OK[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,700] DEBUG {org.apache.synapse.transport.http.wire} - << "CorrelationId: 685454f5-e5f6-4837-b0b0-1e9e53798ea9[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,700] DEBUG {org.apache.synapse.transport.http.wire} - << "Content-Type: application/json[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,700] DEBUG {org.apache.synapse.transport.http.wire} - << "Date: Wed, 28 Mar 2018 14:56:48 GMT[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,700] DEBUG {org.apache.synapse.transport.http.wire} - << "Server: WSO2-PassThrough-HTTP[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,700] DEBUG {org.apache.synapse.transport.http.wire} - << "Transfer-Encoding: chunked[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,700] DEBUG {org.apache.synapse.transport.http.wire} - << "Connection: Keep-Alive[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,700] DEBUG {org.apache.synapse.transport.http.wire} - << "[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,701] DEBUG {org.apache.synapse.transport.http.wire} - << "0[\r][\n]" {org.apache.synapse.transport.http.wire}
TID: [0] [ESB] [2018-03-28 15:56:48,701] DEBUG {org.apache.synapse.transport.http.wire} - << "[\r][\n]" {org.apache.synapse.transport.http.wire}
JSON Payload sent from wiremock to ESB:
{"result": 1}
I played around with using a payloadFactory but I got the same result regardless. I'll include the payloadFactory code I used if it helps:
<payloadFactory media-type="json">
<format>{"amount": $1}</format>
<args>
<arg evaluator="json" expression="$.result"/>
</args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<property name="contentType" value="application/json" scope="axis2"/>
Any help to solving this or things to try will be much appreciated!
Try using <arg evaluator="Xml" expression="//*[local-name()='result']"/> rather than <arg evaluator="json" expression="$.result"/>
I solved this in the end. Turned out to be a conflict between message builders in my axis2.xml properties so the message was never getting built correctly. Thanks for the suggestions anyway!
I have a small Rest-Service App (Java 8, Spring 4.1.6, Spring Security 5.0.1, Jetty 9.3) and i'am accessing some services by JSON using Spring RestTemplate. Until now csfr was disabled, now i want to enable it.
As is understood csfr there is a common token (the client sends it with each request, the server stores it in the session) which is compared on server side. Access is denied if there is no token available or the token is different.
So i thought it would be a good idea to do this token-adding by using an interceptor. I also read, that in json i have to send the token as a header-parameter... but i did something wrong, already the login fails.
Here is the login-source:
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
form.add("username", username);
form.add("password", password);
return restTemplate.postForLocation(serverUri + "login", form);
Here the source of the interceptor:
import java.io.IOException;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
public class MyCsfrInterceptor implements ClientHttpRequestInterceptor{
public static final String CSRF_TOKEN_HEADER_NAME = "X-CSRF-TOKEN";
public static final String csrfSessionToken = UUID.randomUUID().toString();
private static Logger LOG = LoggerFactory.getLogger(MyCsfrInterceptor.class);
#Override
public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
LOG.info("My interceptor called!");
if (request.getMethod() == HttpMethod.DELETE ||
request.getMethod() == HttpMethod.POST ||
request.getMethod() == HttpMethod.PATCH ||
request.getMethod() == HttpMethod.PUT){
LOG.info("Setting csrf token...");
request.getHeaders().add(CSRF_TOKEN_HEADER_NAME, csrfSessionToken);
}
return execution.execute(request, body);
}
}
Here is the log output on client side:
23:24:40.605 [main] DEBUG c.m.l.w.client.StatefulRestTemplate - Created POST request for "http://localhost:8080/login"
23:24:40.610 [main] DEBUG c.m.l.w.client.StatefulRestTemplate - Writing [{username=[user], password=[user]}] using [org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#618b19ad]
23:24:40.615 [main] INFO c.m.l.w.client.MyCsfrInterceptor - My interceptor called!
23:24:40.615 [main] INFO c.m.l.w.client.MyCsfrInterceptor - Setting csrf token...
23:24:40.650 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: best-match
23:24:40.670 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
23:24:40.675 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://localhost:8080][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
23:24:40.705 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://localhost:8080][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
23:24:40.710 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {}->http://localhost:8080
23:24:40.715 [main] DEBUG o.a.h.i.c.HttpClientConnectionOperator - Connecting to localhost/127.0.0.1:8080
23:24:40.715 [main] DEBUG o.a.h.i.c.HttpClientConnectionOperator - Connection established 127.0.0.1:54712<->127.0.0.1:8080
23:24:40.715 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request POST /login HTTP/1.1
23:24:40.715 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
23:24:40.720 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
23:24:40.720 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /login HTTP/1.1
23:24:40.720 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: application/x-www-form-urlencoded
23:24:40.720 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-CSRF-TOKEN: 99ca8171-b8e0-4b95-8d06-3759a874c64b
23:24:40.720 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 27
23:24:40.720 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: localhost:8080
23:24:40.720 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
23:24:40.720 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.4 (java 1.5)
23:24:40.720 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /login HTTP/1.1[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: application/x-www-form-urlencoded[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-CSRF-TOKEN: 99ca8171-b8e0-4b95-8d06-3759a874c64b[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 27[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: localhost:8080[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.4 (java 1.5)[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
23:24:40.720 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "username=user&password=user"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 403 Expected CSRF token not found. Has your session expired?[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Sat, 15 Aug 2015 21:24:40 GMT[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Pragma: no-cache[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "X-XSS-Protection: 1; mode=block[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Frame-Options: DENY[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "X-Content-Type-Options: nosniff[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Set-Cookie: JSESSIONID=1bvmexep1lv9h1qja44hflx0wg;Path=/[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: text/html;charset=iso-8859-1[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Cache-Control: must-revalidate,no-cache,no-store[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 409[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: Jetty(9.3.0.RC1)[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<html>[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<head>[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<title>Error 403 Expected CSRF token not found. Has your session expired?</title>[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "</head>[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<body><h2>HTTP ERROR 403</h2>[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<p>Problem accessing /login. Reason:[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<pre> Expected CSRF token not found. Has your session expired?</pre></p><hr>Powered by Jetty:// 9.3.0.RC1<hr/>[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "</body>[\n]"
23:24:40.831 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "</html>[\n]"
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 403 Expected CSRF token not found. Has your session expired?
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Sat, 15 Aug 2015 21:24:40 GMT
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Pragma: no-cache
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << X-XSS-Protection: 1; mode=block
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << X-Frame-Options: DENY
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << X-Content-Type-Options: nosniff
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Set-Cookie: JSESSIONID=1bvmexep1lv9h1qja44hflx0wg;Path=/
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: text/html;charset=iso-8859-1
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Cache-Control: must-revalidate,no-cache,no-store
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 409
23:24:40.836 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Server: Jetty(9.3.0.RC1)
23:24:40.846 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
23:24:40.861 [main] DEBUG o.a.h.c.p.ResponseProcessCookies - Cookie accepted [JSESSIONID="1bvmexep1lv9h1qja44hflx0wg", version:0, domain:localhost, path:/, expiry:null]
23:24:40.861 [main] DEBUG c.m.l.w.client.StatefulRestTemplate - POST request for "http://localhost:8080/login" resulted in 403 (Expected CSRF token not found. Has your session expired?); invoking error handler
23:24:40.866 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 0][route: {}->http://localhost:8080] can be kept alive indefinitely
In spring security config i didn't do any csrf configuration.
So what's wrong? Did i set the header wrong? Any config missing?
Best regards and thank you for your time.
Looking at your code, it seems that you are generating the CSRF token yourself. But, as I understand, Spring Security CSRF handling would work this way:
Spring Security would generate the CSRF token.
Whenever a request comes (say a GET request) Spring Security will attach the token as a request parameter. This helps rendering JSP forms with the token as a hidden field, like this:
<form action="/foo/5/update" method="post">
<input type="text" ... />
<input type="submit" value="Update" />
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
Whenever a POST like request comes (say a form getting submitted), Spring Security will match its token with the one submitted as a parameter or header.
(2) above works well when we are using JSP etc. But, when we are calling an API, we will first need to fetch the token. A common practice to do that is to have a filter at the server side, attaching the token as a cookie. This is my filter code in a project:
public class CsrfCookieFilter extends OncePerRequestFilter {
public static final String XSRF_TOKEN_COOKIE_NAME = "XSRF-TOKEN";
#Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
log.debug("Inside CsrfCookieFilter ...");
CsrfToken csrf = (CsrfToken)
request.getAttribute(CsrfToken.class.getName()); // Or "_csrf" (See CSRFFilter.doFilterInternal).
if (csrf != null) {
Cookie cookie = WebUtils.getCookie(
request, XSRF_TOKEN_COOKIE_NAME);
String token = csrf.getToken();
if (cookie==null ||
token!=null && !token.equals(cookie.getValue())) {
cookie = new Cookie(XSRF_TOKEN_COOKIE_NAME, token);
cookie.setPath("/");
response.addCookie(cookie);
}
}
filterChain.doFilter(request, response);
}
}
So, before a POST request, a GET request first should come and fetch the token as a cookie. The token then should be sent back as a header in subsequent requests.
My code for wiring this filter and altering the header name looks like this inside inside my security configuration class:
#Override
protected void configure(HttpSecurity http) throws Exception {
http
...
.addFilterAfter(csrfCookieFilter(), CsrfFilter.class)
...
}
protected Filter csrfCookieFilter() {
return new CsrfCookieFilter();
}
Also, note that Spting Security changes the token after certain events like login and logout. So, we need to again fetch the token with a GET request.
The official Spring Angular guide has elaborated it in details.
Why is JSON payload for int-http:outbound-gateway give 400 Bad Request?
Below request works fine on Chrome Rest Client with 3 headers specified in inObjgateway and JSON value of Obj
public class Obj {
#JsonProperty("phone")
private String phoneNo;
#JsonProperty("orderNumber")
private String orderNmb;
}
Application Context Code Snippet is
<int:gateway id="inObjGateway" service-interface="com.XXX.xx.IObjGateway"
default-request-channel="smsHttpRequestChannel" default-reply-timeout="10000">
<int:default-header name="content-Type" value="application/json" />
<int:default-header name="authorization" value="someWE6JHRhcGwzc0MwZDNCcsome"/>
<int:default-header name="accept" value="application/json" />
</int:gateway>
<int:payload-type-router input-channel="httpRequestChannel">
<int:mapping type="com.xxx.xx.json.entity.Obj" channel="httpObjToJsonChannel"/>
</int:payload-type-router>
<int:channel id="httpRequestChannel"/>
<int:channel id="httpOutChannel"/>
<int:channel id="httpObjToJsonChannel"/>
<int:object-to-json-transformer auto-startup="true"
id="objectToJsonTxr" input-channel="httpObjToJsonChannel"
output-channel="smsHttpOutChannel"/>
<bean id="httpRequestFactory" class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">
<property name="connectTimeout" value="${connectionTimeout}"/>
<property name="readTimeout" value="${connectionTimeout}"/>
</bean>
<bean id="jackson2http" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
<int-http:outbound-gateway request-channel="httpOutChannel" encode-uri="false"
url="http://www.someurl.com/something"
http-method="POST" auto-startup="true" request-factory="httpRequestFactory"
reply-channel="loggingChannel" message-converters="jackson2http"
reply-timeout="10000" />
Below line in detailed logs after show correct conversion from Object to JSON-:
Writing [{"phoneNo":"1617xxxxxxx","orderNmb":"2073xxxxx"}] as "application/json"
Detailed logs
org.springframework.beans.factory.support.DefaultListableBeanFactory : Returning cached instance of singleton bean 'integrationEvaluationContext'
org.springframework.integration.router.PayloadTypeRouter : (inner bean)#53c8bb96 received message: GenericMessage [payload=com.xxxx.json.entity.Obj#235a8276, headers={timestamp=1430802166667, id=f3c3577d-bf44-b54d-b5e6-6b3f88a5746b, content-Type=application/json, accept=application/json, authorization=someWE6JHRhcGwzc0MwZDNCcsome}]
org.springframework.beans.factory.support.DefaultListableBeanFactory : Returning cached instance of singleton bean 'ObjHttpObjToJsonChannel'
org.springframework.integration.transformer.MessageTransformingHandler : org.springframework.integration.transformer.MessageTransformingHandler#0 received message: GenericMessage [payload=com.xxxx.json.entity.Obj#235a8276, headers={timestamp=1430802166667, id=f3c3577d-bf44-b54d-b5e6-6b3f88a5746b, content-Type=application/json, accept=application/json, authorization=someWE6JHRhcGwzc0MwZDNCcsome}]
org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler : org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler#2 received message: GenericMessage [payload={"phoneNo":"16173313826","orderNmb":"2070000383","firstName":"A"}, headers={timestamp=1430802166759, id=7584cee1-8392-c71c-75f4-026d423e26c2, json__TypeId__=class com.xxxx.json.entity.Obj, content-Type=application/json, accept=application/json, authorization=someWE6JHRhcGwzc0MwZDNCcsome, contentType=application/json}]
org.springframework.integration.http.support.DefaultHttpHeaderMapper : outboundHeaderNames=[Accept, Accept-Charset, Accept-Encoding, Accept-Language, Accept-Ranges, Authorization, Cache-Control, Connection, Content-Length, Content-Type, Cookie, Date, Expect, From, Host, If-Match, If-Modified-Since, If-None-Match, If-Range, If-Unmodified-Since, Max-Forwards, Pragma, Proxy-Authorization, Range, Referer, TE, Upgrade, User-Agent, Via, Warning]
org.springframework.integration.http.support.DefaultHttpHeaderMapper : headerName=[timestamp] WILL NOT be mapped
org.springframework.integration.http.support.DefaultHttpHeaderMapper : headerName=[id] WILL NOT be mapped
org.springframework.integration.http.support.DefaultHttpHeaderMapper : headerName=[json__typeid__] WILL NOT be mapped
org.springframework.integration.http.support.DefaultHttpHeaderMapper : headerName=[content-type] WILL be mapped, matched pattern=content-type
org.springframework.integration.http.support.DefaultHttpHeaderMapper : setting headerName=[content-Type], value=application/json
org.springframework.integration.http.support.DefaultHttpHeaderMapper : headerName=[accept] WILL be mapped, matched pattern=accept
org.springframework.integration.http.support.DefaultHttpHeaderMapper : setting headerName=[accept], value=application/json
org.springframework.integration.http.support.DefaultHttpHeaderMapper : headerName=[authorization] WILL be mapped, matched pattern=authorization
org.springframework.integration.http.support.DefaultHttpHeaderMapper : setting headerName=[authorization], value=someWE6JHRhcGwzc0MwZDNCcsome
org.springframework.integration.http.support.DefaultHttpHeaderMapper : headerName=[contenttype] WILL be mapped, matched pattern=contenttype
org.springframework.integration.http.support.DefaultHttpHeaderMapper : setting headerName=[contentType], value=application/json
org.springframework.web.client.RestTemplate : Created POST request for "http://www.someurl.com/something"
org.springframework.web.client.RestTemplate : Writing [{"phoneNo":"1617xxxxxxx","orderNmb":"2073xxxxx"}] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter#774490f3]
org.springframework.web.client.RestTemplate : POST request for "http://www.someurl.com/something" resulted in 400 (Bad Request); invoking error handler
org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver : Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.xxxx.page.controller.ObjController.sendObj(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpSession) throws com.xxxx.utils.exception.SomePageException]: org.springframework.web.client.HttpClientErrorException: 400 Bad Request
org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver : Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.xxxx.page.controller.ObjController.sendObj(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpSession) throws com.xxxx.utils.exception.SomePageException]: org.springframework.web.client.HttpClientErrorException: 400 Bad Request
org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver : Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.xxxx.page.controller.ObjController.sendObj(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpSession) throws com.xxxx.utils.exception.SomePageException]: org.springframework.web.client.HttpClientErrorException: 400 Bad Request
org.springframework.web.servlet.handler.SimpleMappingExceptionResolver : Resolving exception from handler [public org.springframework.web.servlet.ModelAndView com.xxxx.page.controller.ObjController.sendObj(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,javax.servlet.http.HttpSession) throws com.xxxx.utils.exception.SomePageException]: org.springframework.web.client.HttpClientErrorException: 400 Bad Request
org.springframework.web.servlet.handler.SimpleMappingExceptionResolver : Resolving to view 'error' for exception of type [org.springframework.web.client.HttpClientErrorException], based on exception mapping [java.lang.Exception]
org.springframework.web.servlet.handler.SimpleMappingExceptionResolver : Exposing Exception as model attribute 'exception'
org.springframework.web.servlet.DispatcherServlet : Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'error'; model is {exception=org.springframework.web.client.HttpClientErrorException: 400 Bad Request}
org.springframework.web.client.HttpClientErrorException: 400 Bad Request
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:588)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:546)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:517)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:462)
at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:422)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:277)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:239)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:95)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutput(AbstractMessageProducingHandler.java:248)
at org.springframework.integration.handler.AbstractMessageProducingHandler.produceOutput(AbstractMessageProducingHandler.java:171)
at org.springframework.integration.handler.AbstractMessageProducingHandler.sendOutputs(AbstractMessageProducingHandler.java:119)
at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:105)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:277)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:239)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:95)
at org.springframework.integration.router.AbstractMessageRouter.handleMessageInternal(AbstractMessageRouter.java:164)
at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:78)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOptimizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:101)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:97)
at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:277)
at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:239)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:115)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(GenericMessagingTemplate.java:45)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.send(AbstractMessageSendingTemplate.java:95)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:133)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.convertAndSend(AbstractMessageSendingTemplate.java:125)
at org.springframework.integration.gateway.MessagingGatewaySupport.send(MessagingGatewaySupport.java:302)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invokeGatewayMethod(GatewayProxyFactoryBean.java:417)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.doInvoke(GatewayProxyFactoryBean.java:374)
at org.springframework.integration.gateway.GatewayProxyFactoryBean.invoke(GatewayProxyFactoryBean.java:365)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy102.sendObj(Unknown Source)
at com.xxxx.page.controller.ObjController.sendObj(ObjController.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:606)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
The Wireshark packet trace difference from what I observed is as below.
Working request trace from Postman Rest Client!
No. Time Source Destination Protocol Length Info
16733 484.996811000 10.1.XX.XXX 192.XX.XX.XXX HTTP 1126 POST /chapi/v1/some HTTP/1.1 HTTP/1.1 (application/json)
Frame 16733: 1126 bytes on wire (9008 bits), 1126 bytes captured (9008 bits) on interface 1
Ethernet II, Src: HewlettP_2d:4e:49 (a0:2b:xx:xx:xx:49), Dst: Cisco_ff:fc:04 (00:08:xx:xx:fx:04)
Internet Protocol Version 4, Src: 10.1.XX.XXX (10.1.XX.XXX), Dst: 192.XX.XX.XXX (192.XX.XX.XXX)
Transmission Control Protocol, Src Port: 60374 (60374), Dst Port: 80 (80), Seq: 2921, Ack: 1, Len: 1072
[3 Reassembled TCP Segments (3992 bytes): #16728(1460), #16729(1460), #16733(1072)]
[Frame: 16728, payload: 0-1459 (1460 bytes)]
[Frame: 16729, payload: 1460-2919 (1460 bytes)]
[Frame: 16733, payload: 2920-3991 (1072 bytes)]
[Segment count: 3]
[Reassembled TCP length: 3992]
[Reassembled TCP Data: 504f5354202f6d6f62696c6553657276696365732f737470...]
Hypertext Transfer Protocol
POST /chapi/v1/some HTTP/1.1\r\n
Host: something.com\r\n
Connection: keep-alive\r\n
Content-Length: 94\r\n
Accept: application/json\r\n
Cache-Control: no-cache\r\n
Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm\r\n
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36\r\n
Authorization: someWE6JHRhcGwzc0MwZDNCcsome\r\n
Content-Type: application/json\r\n
Accept-Encoding: gzip, deflate\r\n
Accept-Language: en-US,en;q=0.8\r\n
[truncated]Cookie: _br_mzv=eyIxIjozLCIyIjox
\r\n
[Full request URI: http://www.something.com//chapi/v1/some ]
[HTTP request 1/1]
[Response in frame: 16746]
JavaScript Object Notation: application/json
Object
Member Key: "phone"
String value: 1617xxxXXXX
Member Key: "orderNumber"
String value: 12xxXXXXX
Member Key: "application"
String value: orderPickup
Request not working from Application as per above code configuration !
No. Time Source Destination Protocol Length Info
89769 2664.453624000 10.1.XX.XXX 192.XX.XX.XXX HTTP 491 POST /chapi/v1/some HTTP/1.1 (application/json)
Frame 89769: 491 bytes on wire (3928 bits), 491 bytes captured (3928 bits) on interface 1
Ethernet II, Src: HewlettP_xx:xx:49 (a0:2b:xx:xx:xx:49), Dst: Cisco_ff:fc:04 (00:08:xx:xx:fx:04)
Internet Protocol Version 4, Src: 10.1.XX.XXX (10.1.XX.XXX), Dst: 192.XX.XX.XXX (192.XX.XX.XXX)
Transmission Control Protocol, Src Port: 60618 (60618), Dst Port: 80 (80), Seq: 1, Ack: 1, Len: 437
Hypertext Transfer Protocol
POST /chapi/v1/some HTTP/1.1\r\n
Accept: application/json\r\n
authorization: someWE6JHRhcGwzc0MwZDNCcsome\r\n
Content-Type: application/json\r\n
Content-Length: 91\r\n
Host: something.com\r\n
Connection: Keep-Alive\r\n
User-Agent: Apache-HttpClient/4.3.6 (java 1.5)\r\n
Accept-Encoding: gzip,deflate\r\n
\r\n
[Full request URI: http://www.something.com/chapi/v1/some]
[HTTP request 1/1]
[Response in frame: 89778]
JavaScript Object Notation: application/json
Line-based text data: application/json
"{\"phoneNo\":\"1617xxxXXXX\",\"orderNmb\":\"207xxXXXX\",\"application\":\"orderPickup\"}"
Any pointers appreciated!
Questions like this are too general; you need to provide more details.
This requires you to use some basic debugging skills.
Step 1: Look at the server side logs to see what it is complaining about.
If that doesn't yield the solution,
Step 2: Compare a network monitor trace of the "good" and "bad" requests and figure out what's different between them. If you see what's different and can't figure out how to configure the gateway to replicate the "good" request then come back here with that specific question.
You can get a network trace with Wireshark or the eclipse TCP/IP Monitor, etc.
EDIT:
As you can see from the trace, you are doing two JSON conversions.
Remove the object-to-json-transformer and just let the outbound gateway do the conversion.