Springws and MTOM client KO when pass through a balancer - mtom

I have a problem with a client that sends a pdf binary document with MTOM enabled to a soapservice. The service is correctly exposed and served. When i call the endpoint of the server that expose the service all goes ok, when i call the same service through a "service gateway" it sends back a "bad request" after it receive all the request.
>Accept-Encoding: gzip
>Content-Type: multipart/related;type="application/xop+xml";start-info="text/xml"
>Content-Disposition: attachment
>Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
>SOAPAction: "http://ws.documents...."
>Content-Type: Multipart/Related; boundary="----=_Part_1_1067527082.1584978884916"; >type="application/xop+xml"; start-info="text/xml"
>Cache-Control: no-cache
>Pragma: no-cache
>User-Agent: Java/1.8.0_222
>Host: service.xx.yy:8080
>Connection: keep-alive
>Content-Length: 105614
....
> This is the trace of the service gateway:
> v^[¹‹‘HTTP/1.1 400 [ISC.0064.9101] Bad Request Connection: close
> Content-Length: 0
The same service gateway is a passthrough of all other services without mtom and all goes ok.
The weird thing is that when i call with soapui with attachment and MTOM enabled through the service gateway the call ends correctly.
This is the core of the code:
response = (JAXBElement<CreateDocumentsResponseType>) wst.marshalSendAndReceive(uri,request);
Where wst is a normal WebServiceTemplate instance with MTOM enabled
request is the envelope marshalled with the document already packed with datahandler.
Before send the message, i made an interceptor to set the request header with custom authentication.

The balancer made a "preflight" that the webservicetemplate don't treat correctly. Created custom interceptor to handle this.

Related

REST client gives error, while HTTP looks fine

My interface (an MKR Wifi 1010 Arduino) runs a very simple REST API, but when testing it with Mulesoft's Advanced Rest Client, I get this error:
The requested URL can't be reached
The service might be temporarily down or it may have moved permanently to a new web address.
The response status "0" is not allowed. See HTTP spec for more details: https://tools.ietf.org/html/rfc2616#section-6.1.1
When I check it with telnet though, it looks fine:
[bf#localhost ~]$ telnet 192.168.178.185 80
Trying 192.168.178.185...
Connected to 192.168.178.185.
Escape character is '^]'.
GET /api/gps HTTP/1.1
Host: 192.168.178.185
HTTP/1.1 200 OK
Connection: close
Content-Length: 9
Content-Type: application/json
"Success"
Connection closed by foreign host.
My question now is, is the rest client broken, or am I missing something in my reply? Of course I want any REST client to be able to process my interface correctly.

JAX WS generated client gets "Unable to determine SOAP version" from new Axis2 versions

We have SOAP Web Service running on Axis2-server. On client side we use JAX WS generated client. We tried to updgrade our Axis2-server from 1.6.2 to 1.7.7 and found that JAX WS client doesn't work anymore. Server returns "Unable to determine SOAP version" from Axis2-server. I searched that "Unable to determine SOAP version" error is coming from axiom library which reads type parameter from Content-Type of SOAP message.
Example of SOAP request headers:
Accept: application/soap+xml, multipart/related
Content-Type: multipart/related;start="<rootpart*897f69f7-8c00-461b-a0c3-08d07ea4e433#example.jaxws.sun.com>";type="application/xop+xml";boundary="uuid:897f69f7-8c00-461b-a0c3-08d07ea4e433";start-info="application/soap+xml;action=\"Authenticate\""
User-Agent: JAX-WS RI 2.2.9-b130926.1035 svn-revision#5f6196f2b90e9460065a4c2f4e30e065b245e51e
--uuid:897f69f7-8c00-461b-a0c3-08d07ea4e433
Content-Id: <rootpart*897f69f7-8c00-461b-a0c3-08d07ea4e433#example.jaxws.sun.com>
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml;action=\"Authenticate\""
Content-Transfer-Encoding: binary
This is in fact a bug in Apache Axiom; see AXIOM-492.

OSB - Processing Http errors from Restful service in Proxy Service

I'm invoking a REST service from an OSB Proxy Service, which is working fine if the rest service response is a valid response, i.e., there's no errors. However if the rest service replies with an http error code (e.g. 400 Bad Request), I'm not able to capture anything else except the http error code:
$fault variable in OSB:
<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>BEA-382502</con:errorCode>
<con:reason>
OSB Service Callout action received an error response
</con:reason>
<con:details>
<con1:ErrorResponseDetail xmlns:con1="http://www.bea.com/wli/sb/stages/transform/config">
<con1:http-response-code>400</con1:http-response-code>
</con1:ErrorResponseDetail>
</con:details>
<con:location>
<con:node>PipelinePairNode1</con:node>
<con:pipeline>PipelinePairNode1_request</con:pipeline>
<con:stage>stage1</con:stage>
<con:path>request-pipeline</con:path>
</con:location>
</con:fault>
But the rest service, is not only replying with 400 Bad Request, but also adding a message:
<Error>
<Message>The message header contains an invalid brand code.</Message>
</Error>
Which I'm not able to process in my proxy service. Does anyone knows if it is possible to access this message details in OSB or is it a limitation?
The rest service is clearly sending the message, because invoking it directly through soap-ui I'll get the following response:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 84
Content-Type: application/xml; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 09 Feb 2015 16:15:32 GMT
<Error><Message>The message header contains an invalid brand code.</Message></Error>
Thanks
I've just found out this is an OSB bug, in case of an HTTP Error code 400 being returned, if the http-content is "Application/XML" the message is ignored.
Oracle released a Patch at the end of last month to fix this issue, which I've tested and it works. I can get the message details in the $body variable now.
Patch: 16986497
If I understand your question, you want to get in addition to the http code, the message error?
I think you should use, in your message flow, an errorHandler , so that you can catch the error and do whatever you want with.
The proxy service operation selection algorithm cannot determine the operation name from the request or returns an invalid operation (one which is not in the WSDL or null). Possible reasons include the following:
An error occurs while computing the operation.
The operation selection algorithm returns null.
The operation selection algorithm returns an operation that is not of the of the operations declared by the WSDL.
Source

ReST: how can client tell server to return `Content-disposition: attachment`

So lets say I have a resource at /things.
If client does GET /things/myid I'll serve the default response (json).
If client passes an Accept: csv header I will serve the response as csv.
But what if I want to enable the client to tell the server to include a Content-disposition: attachment header in the response (to force a download)?

403 forbidden message while executing a rest message through Jmeter

I am trying to test a Rest service through HTTP sampler using Jmeter. The first sampler generates a token and I am using this token for authorization in the header manager of another HTTP sampler "GetUserandPolicies"(Rest WS request) using RegEx and ForEach controller. I can see in the view results tree that RegEx is working fine passing the actual token to the next request. But the Rest Request is failing giving a response message as Forbidden and Response Code 403 which means that the server is able to recognise the request but denying the access.There is no port number for this HTTP sampler which I suspect would be the culprit. But, the same test is passing with another tool (iTKO LISA) without any port value. Both the samplers "TokenGeneration" and "GetUserandPolicies" have no port values. I need some help on this. I am using the POST method in the HTTP sampler
Please find the sampler result:
Thread Name: Thread Group 1-1
Sample Start: 2014-01-13 12:12:29 IST
Load time: 1390
Latency: 1390
Size in bytes: 382
Headers size in bytes: 354
Body size in bytes: 28
Sample Count: 1
Error Count: 1
Response code: 403
Response message: Forbidden
Response headers:
HTTP/1.1 403 Forbidden
Server: Apache-Coyote/1.1
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Authorization, X-Requested-With, Content-Type
Content-Type: text/plain;charset=UTF-8
Content-Length: 28
Date: Mon, 13 Jan 2014 06:42:30 GMT
HTTPSampleResult fields:
ContentType: text/plain;charset=UTF-8
DataEncoding: UTF-8
Looking into Access-Control-Allow-Headers: Authorization, X-Requested-With, Content-Type stanza I guess that you're missing proper Authorization header.
In regards to empty port everything is fine, it defaults to port 80 in case of HTTP and 443 in case of HTTPS
There are 2 options on how you can deal with Basic HTTP Authentication:
Pass username and password in URL like protocol://username:password#host:port/path
i.e. http://user:pass#your.server.com/somelocation
Use JMeter HTTP Authorization Manager to construct required "Authorization" header for you.
In case if your authentication system uses other approaches, i.e. Cookie-based, NTLM or Kerberos it's still possible but a little bit more tricky. If so - update this post with all details you can get (i.e. request details) and don't hesitate to leave a comment requesting for more input