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

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.

Related

Springws and MTOM client KO when pass through a balancer

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.

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

wso2 ESB request is truncated

i'm using fresh installation of wso2 esb 4.8.1 with stanalone default configuration.
when i send soap request to my backend (perl service with soap lite), the body of POST request is truncated like this according to tcpdump:
SOAPAction: ""
Content-Type: text/xml
Content-Length: 511
Host: 192.168.11.234:8181
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="htt
p://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<deleteAccountForHost xmlns="AbcdeHostingPhysicalHostManagerCPanelService">
<host xsi:type="xsd:string">zs000.abcde.net</host>
<user xsi:type="xsd:string">tstauto</user>
</deleteAccountForHost>
</soap:Body>
</soap:Envel
You can see that closing tag '</soap:Envel' is truncated.
But when i enable SOAP-tracer the request body becomes valid.
i use PT transport. I tried to switch transport to the nhttp and this problem seems to be disappeared.
So the question is: how to configure PT transport to avoid such strange behavior?
UPD1:
it seems that the problem occurs only when set the property FORCE_HTTP_1.0 and transport is PT
I got the same problem, but I set DISABLE_CHUNKING.
After many tries I tested that disabling chunking or forcing HTTP 1.0 results in truncated request.
I use WSO2 ESB version 4.8.1, client is SoapUI 5.0.0 or SoapClient from PHP 5.5.11.
When I use "Try this service" in ESB, then request is not truncated.
After switching from HTTP PassThrough Transport to HTTP-NIO Transport service behind endpoint receives complete request, but then I can't download WSDL of tenant.

How to use #HEAD in jax-rs using Jersey API or any other jax-rs API?

How to use #HEAD in jax-rs using Jersey API or any other jax-rs API ? please give me sample.
You don't need to explicitly support HEAD as Jersey will automatically support it. Here is what Jersey's the documentation says:
By default the JAX-RS runtime will automatically support the methods HEAD and OPTIONS, if not explicitly implemented. For HEAD the runtime will invoke the implemented GET method (if present) and ignore the response entity (if set). For OPTIONS the Allow response header will be set to the set of HTTP methods support by the resource. In addition Jersey will return a WADL document describing the resource.
(Source: https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/user-guide.html#d0e2157)
Here is some dirt simple code illustrating how to send a HEAD request using the Jersey client:
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource resource = client
.resource("http://localhost:8080/services/echo?message=Hello+World");
ClientResponse response = resource.accept(
MediaType.APPLICATION_JSON).head();
System.out.println(response);
Note the use of the head method. The response object returned contains lots of useful information, like the content type produced, the status code of the request, etc etc. The example can be translated to other client library types, but basically you send exactly the same request as you would with a GET, but with the HEAD method instead. Heres an example of the request that would be sent via a browser tool like 'REST Console':
Request
HEAD /services/echo?message=Hello+World HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Content-Length: 0
Accept: application/json
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
Cookie: JSESSIONID=vWu5N2H8Y+P9SuZKWxhpIdgP.undefined
Response:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: application/json
Content-Length: 0
Date: Fri, 03 May 2013 05:42:20 GMT

Invoking external web methods with BPEL + Apache Ode (calling .Net asmx) problems

Pre-info:
I'm learning to use orchestration of web methods(WM). I've sucessfully completed lessons with assings, invoking web methods, some parallel processing in BPEL. I'm using Eclipse Indigo 3.7.1 with BPEL plugins, Tomcat7 server with Apache Ode as orchestration base. At other side I need to learn calling secured WMs written on Mono .Net platform.
Having now:
Now I'm having problem calling ANY web methods. I've made:
1) Web Method running by Mono .Net - works, can be tested with browser (http://localhost:8081/hwws.asmx ) and with Eclipse tool "Web Services Explorer", it works fine.
2) my BPEL that only invokes this .Net web method throught SOAP port.
3) at other work stantion I've made .Net service with Visual Studio. Having errors either, if need I'll post it text later.
Problem: I'm getting errors at invoking.
Screens:
1) browser test of .net WS HW(helloWorld) http :// photo -hosting.winsoftmagic .com/ 1/ s4nbwdsqib.jpg
2) Eclipse test of .net WS HW http://photo-hosting.winsoftmagic.com/1/zywnl2wtgu.jpg
3) Error I get http://photo-hosting.winsoftmagic.com/1/ltbexoxcdl.jpg
Error listing:
18:15:25,294 WARN ExternalService Fault response: faultType=(unkown)
soap:ClientCould not deserialize Soap message
18:15:25,376 ERROR INVOKE Failure during invoke:
18:15:25,382 INFO BpelRuntimeContextImpl ActivityRecovery: Registering activity 11, failure reason: on channel 21
And it's give timeout error later. I've spent a week around this problems already, searched with all ways I could think up.
EDIT 12.03.2012:
Now test with mono WS worked for some reason.
I've tryed call WS from the internet and it gave the same error as I had at work spot:
14:25:16,177 ERROR [INVOKE] Failure during invoke: Error sending message (mex={PartnerRoleMex#hqejbhcnphr747jefui9ic [PID {http://wsaspx.tns/}inetWS-24] calling org.apache.ode.bpel.epr.WSAEndpoint#1e3a4c7.checkText(...) Status ASYNC}): The input stream for an incoming message is null.
14:25:16,178 INFO [BpelRuntimeContextImpl] ActivityRecovery: Registering activity 11, failure reason: Error sending message (mex={PartnerRoleMex#hqejbhcnphr747jefui9ic [PID {http://wsaspx.tns/}inetWS-24] calling org.apache.ode.bpel.epr.WSAEndpoint#1e3a4c7.checkText(...) Status ASYNC}): The input stream for an incoming message is null. on channel 21
In same time this service works from all test forms.
Edit: 16.03.2012
My mono method stopped work same as it started without my understanding. TcpMon-1.1.jar shows such message again:
POST /hwws.asmx HTTP/1.1
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://hwws.tps/HelloWorld"
User-Agent: Axis2
Host: localhost:8092
Transfer-Encoding: chunked <--- EDITED: REASON OF NOT WORKING ----
31c
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<addr:To xmlns:addr="http://www.w3.org/2005/08/addressing">http://localhost:8092/hwws.asmx</addr:To>
<addr:Action xmlns:addr="http://www.w3.org/2005/08/addressing">http://hwws.tps/HelloWorld</addr:Action>
<addr:ReplyTo xmlns:addr="http://www.w3.org/2005/08/addressing"><addr:Address>http://www.w3.org/2005/08/addressing/anonymous</addr:Address></addr:ReplyTo>
<addr:MessageID xmlns:addr="http://www.w3.org/2005/08/addressing">uuid:hqejbhcnphr74k7fapcntd</addr:MessageID>
</soapenv:Header>
<soapenv:Body><HelloWorld xmlns="http://hwws.tps/">
<s0:st xmlns:s0="http://hwws.tps/">My test message</s0:st>
</HelloWorld></soapenv:Body></soapenv:Envelope>
0
HTTP/1.0 500 Internal Server Error
Date: Fri, 16 Mar 2012 08:01:50 GMT
Server: Mono.WebServer2/0.4.0.0 Unix
Connection: close
X-AspNet-Version: 4.0.30319
Content-Length: 366
Cache-Control: private
Content-Type: text/xml; charset=utf-8
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body><soap:Fault><faultcode>soap:Client</faultcode>
<faultstring>Could not deserialize Soap message</faultstring>
</soap:Fault></soap:Body></soap:Envelope>
Actually I get one of 3 errors: couldn't deserialise, The input stream for an incoming message is null or even error 411 yesterday:) P.s. had 4th error with no socket connecting also, but all them vanished.
My main goal is ssl+authorisation .net services - would be gratefull if you have examples.
Thanks a lot to everyone! It's real pleasure to see your help:)
Thanks to all, testing soap-body shown that it was good and problem was in headers part which had some strange "Chunked" and numbers before xml (length of xml text) and 0 after xml end. I just set http.request.chunk=false and now it work at all my tests yet. For that purpose download sample.endpoint from http://ode.apache.org/endpoint-configuration.html , renamed it as bpel name (MonoCaller.bpel => MonoCaller.endpoint). It has string for chunked already commented. And also added something like http.default-headers.authorization=Basic <64b code of "login:password" made in any coder> for authorization purpose and it also works now! :-]
The same error has occured with me, the problem was with the web service itself, I had an empty constructor plus the methodes wich causes a problem, the solution is to delete the constructor.