Make CXF Web Service work when there is no internet connection - java

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

Related

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.

Axis2 web service invocation error

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

Web Service SOAP server was unable to process request

Hi I'm develping a web app in Java for a local bank and they have a SOAP Web Service that my app consumes. The app is deployed on GlassFish 3.1.2 and the web service was generated on .Net (I don't know the specifics, I'm new to the project) and everything is connected through a peer to peer VPN.
Now the issue I have is when I try to log in I get an EJBException:
javax.faces.el.EvaluationException: javax.ejb.EJBException
Caused by: com.sun.xml.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Server was unable to process request. ---> Changes to this object and its sub-objects have been disabled (Exception from HRESULT: 0x8011042A) Please see the server log to find more detail regarding exact cause of the failure.
Now I'm trying to determine what exactly is the problem with the web service, or even better what should the guys at the bank check to determine what's wrong.
If anyone knows or has some ideas on what we should check please let me know. Thanks
Seems to be server problem. Send them exactly time stamp of request and all the request details, and they will probably guide you to the problem

Java Web Service error: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog

I have a problem creating and connecting a Java client to a running Web Service.
I use the following code:
Service myService = null;
URL wsdlLocation = new URL("http://myservice?wsdl");
QName serviceName = new QName(wsdlLocation, "MyService");
Service myService = new Service(wsdlLocation, serviceName);
where the Service class was created with the following command:
wsimport -d gen -keep http://myservice?wsdl
I've also tried with a client generated by Apache cxf 2.4's wsdl2java, but got the same result.
(I've changed the WSDL location and Service class name only for this post, in the code I use the original ones.)
But I get an exception when I call the Web Service deployed on the appserver, when creating the service with the new Service() command.
But: I've tested the wsdl location with SOAP UI and it works perfectly.
Also, I've created a Mock Service using Soap UI and my Java client could connect to it, call it and get the results back.
The problem appears when I want' to call the web service running on the appserver.
Stacktrace:
javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:98)
at javax.xml.ws.Service.<init>(Service.java:76)
at MyService.<init>(MyService.java:42)
at mypackage.createService(AClass.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:100)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:199)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
... 12 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col,system-id]: [1,0,"http://myservice?wsdl"]
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:256)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:205)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
... 14 more
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col,system-id]: [1,0,"http://myservice?wsdl"]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:677)
at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2139)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2045)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1248)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:1142)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:1069)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:247)
... 16 more
Could someone please help me?
I encountered this error and found that it appeared to be due to using a URL that returned an HTTP 302 redirect instead of the WSDL directly.
The URL I was using was in the format /Service?wsdl, which redirected to a URL in the format /Service/wsdl/Service.wsdl. Once I used the redirect target URL directly, everything worked.
I remember reading that it could be related to the endpoint expecting a trailing '/'. I'm not sure if this valid, but please try it and post here it if works.
I had a similar error and when I checked the server logs - it was related to http server having encountered an unsupported http method in request. Due to this teh server returns an HTTP response that the SOAP client cannot handle ... hence Unexpected EOF in prolog
Below is a snippet my web-server log for tomcat "localhost.XXXX.log"
org.apache.tomcat.util.descriptor.web.SecurityConstraint.findUncoveredHttpMethods For security constraints with URL pattern [/services/*] only the HTTP methods [POST GET] are covered. All other methods are uncovered.
This gave following error on client side
com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
In my case since I was downgrading a secured service to unsecured and my web.xml had following stray entry that was restricting GET and post with a security constraint and I wasnt sending needed security parameters in the request..
<security-constraint>
<web-resource-collection>
<web-resource-name>restricted web services</web-resource-name>
<url-pattern>/services/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
I removed this constraint to get rid of this error :-)
In your case it may not related to security constraint - but for sure its related to server sending raw http response - Please check your server/ client configuration and ensure it sends appropriate http request that are liked by http server
I had a similar error and when I checked the server logs - it was related to http server having encountered an unsupported http method in request returns an HTTP response that the SOAP client cannot handle ... check your web-server logs
Surely this isn't due to character or format issue.
It's possible that the server didn't return any data, of which the Woodstox (wstx) was trying to parse into XML and failed, which resulted to this error.
I had similiar issue and i have resolved with debugging.
When i try to download WSDL in runtime i found that i could not get the WSDL because of the proxy.
Please check that you can access the WSDL in runtime like this code:
try {
String wsdl = org.apache.commons.io.IOUtils.toString(new URL("http://YOUR_WSDL_URL"));
System.out.println("WSDL => "+wsdl);
} catch (IOException e) {
e.printStackTrace();
}
One of the imports are missing. Please check routes to your xsd's.
I had the same problem. I had to use the full path to the WSDL file to make it works.
My contribution to this error is this:
I don't get this error when I am in debugging mode.
It seems that when the executor of the Java program that queries the WSDL Service (Java in my case) has the time to perform many requests, like in debugging mode, because of when sometimes the programs stops because I put some breakpoints, in this case I don't get this error.
When I run the program in production mode, yes.
But the requests are the same, the WSDL doesn't change, as well ad the endpoints.
It's like a limitation of the web Server, I think.

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.

Categories