Axis2 web service invocation error - java

I tried to create a simple tester for my service and I get this exception:
Exception in thread "main" org.apache.axis2.AxisFault: java.lang.UnsupportedOperationException: An access occurred that is not valid.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.RobustOutOnlyAxisOperation$RobustOutOnlyOperationClient.handleResponse(RobustOutOnlyAxisOperation.java:91)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at pinservice.PinOperationStub.changePin(PinOperationStub.java:496)
at pinservice.PinOperationTester.main(PinOperationTester.java:22)
any help on troubleshooting this error or thoughts on why this happens ?

It is an incorrect use of message receiver (in-out and in-only). Make sure to update services.xml file with correct configuration. More details available in below link with simple example.
http://www.developer.com/services/article.php/3613896/Writing-an-Axis2-Service-from-Scratch.htm

Related

Make CXF Web Service work when there is no internet connection

I have a SOAP CXF Web Service which does not start when there is no internet connection.
Error when one of test was done is as follows
caused by: javax.wsdl.WSDLException: WSDLException (at /definitions/types/xs:schema/xsd:schema/schema): faultCode=PARSER_ERROR: Problem parsing 'file:/C:/<tomcat_instance>/webapps/cxfws/xsd/xmldsig-core-schema.xsd'.: java.net.SocketException: Permission denied: connect
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(WSDLReaderImpl.java:2198) ~[wsdl4j-1.6.3.jar:1.6.3]
Found a link
https://users.cxf.apache.narkive.com/z0jMuziG/running-cxf-on-a-server-that-don-t-have-an-internet-connection
But the suggestion in that is not helping me to resolve the problem
Tried to define
spring.schemas under META-INF with the line
http://www.w3.org/2000/09/xmldsig#/xmldsig-core-schema.xsd=xsd/xmldsig-core-schema.xsd
But this is not helping out to resolve the problem.
Any suggestions?
Also what is the purpose of spring.handlers? Is this also required?
Was able to resolve parsing error on startup of the product by removing wsdlLocation from cxf-beans.xml and also from the #javax.jws.WebService annotation in the SOAP service implementation class

Axis2Fault detailed description

I have created a java client to make web service call to a remote axis2 service deployed. I generated the client stubs with the WSDL file downloaded from the remote server's "/?wsdl" endpoint and tested a sample call for one of the exposed operations. It failed with the AxisFault error:
org.apache.axis2.AxisFault: Exception occurred while trying to invoke service method "sample operation"
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
The above error appears quite generic and doesn't help much in knowing the actual reason. Please suggest a way of getting more detailed error reason. Is there any attribute of AxisFault entity that is populated with a detailed error description which I can log or there is some other way?

Problem writing SAAJ model to stream: Unable to create MessageFactory: Provider for javax.xml.soap.MessageFactory cannot be found

I need to communicate with webservice via SoapHttpPort.
Machine run Apache Tomcat 8.5.23 and Apache Karaf 4.
Webservice need settings of authorization in Soap "Authorization - Basic" and "Outgoing-wss".
When I call port, I receive WebServiceException:
javax.xml.ws.WebServiceException: org.apache.cxf.binding.soap.SoapFault: Error on verifying message against security policy Error code:1000
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:159)
First fix
I tried recommended fix (SecurityHandler class).
JAX-WS Password Type PasswordText
But this fix didn´t solve problem.
I receive another exception.
javax.xml.ws.WebServiceException: org.apache.cxf.binding.soap.SoapFault: Problem writing SAAJ model to stream:Unable to create MessageFactory: Provider for javax.xml.soap.MessageFactory cannot be found
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:159)
Second fix
I tried recommended fixes.
https://github.com/apache/camel/tree/master/examples/camel-example-reportincident-wssecurity
http://forum.spring.io/forum/spring-projects/web-services/38499-unable-to-create-message-factory-for-soap-provider-org-apache-axis-soap-messagefacto
But this fixes didn´t solve problem. WebServiceException is still the same.
Any help would be appreciated.
Thank you very much.

What causes Caused by: javax.xml.ws.soap.SOAPFaultException: Signature was not validated successfully?

I am using a webservice with a client generated by JAXWS and am now getting this error:
Caused by: javax.xml.ws.soap.SOAPFaultException: Signature was not validated successfully
at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:193)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:126)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:123)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:93)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:144)
I can't find anything helpful on this problem. This was working and then stopped working. What I need to know is what conditions will cause this error.
Turns out it was a problem with the SAML token. We have multiple servers and we needed to use a different server.

Exception in thread "main" org.apache.axis2.AxisFault: Read timed out

I wrote a web service and web client was generated using Eclipse wizard.
And my client application is requesting a String and also an Object.
The string can be retrieved successfully and when I tried to retrieve the object it gives the following exception (I'm using JBoss 5):
Exception in thread "main" org.apache.axis2.AxisFault: Read timed out
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:203)
at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400)
at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:435)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at se.cambio.cimonitor.ws.implmnt.GetDataStub.retrieveDetails(GetDataStub.java:203)
at se.cambio.cimonitor.ws.client.WebServiceClient.main(WebServiceClient.java:44)
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read(BufferedInputStream.java:237)
at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77)
at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105)
at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1115)
at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.readLine(MultiThreadedHttpConnectionManager.java:1373)
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1832)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1590)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346)
at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:560)
at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
I cannot find a way out, please help me.
I can only provide help from the only exception stack trace you've place.
The root cause of the exception is:
Caused by: java.net.SocketTimeoutException: Read timed out
It means that a timeout has occurred when the socket tried to read or accept. In your case there was a read timeout.
You need to figure out what is your socket timeout to the service server box and if you can, make it live indefinitely.
I ran into this error on a project, and the root cause was a proxy server setting. I had to modify the proxy to allow the communication to the service I was trying to hit. My code was running as part of a custom application that used its own proxy. So this may also be something to try.
Finally I could overcome the problem. My object was an object which contains another objects inside that. Then I construct a one object with String and int and could send successfully.
Thank you...
We faced similar issue and we were getting Read Time Out while trying to invoke a secured webservice, after a long analysis we found out that there was a mismatch in the transport protocol version. Web-service was servicing on http1.0 and we were invoking it using http1.1. We modified the protocol version in our client code which resolves this issue:
Below is the code to specify http version-1.0 options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_PROTOCOL_VERSION, org.apache.axis2.transport.http.HTTPConstants.HEADER_PROTOCOL_10);

Categories