I try to transfer file with Mtom and it is working pretty good until i use SoapHandler to verify client signature. SoapHandler keeps all message and changes it to base64 encoded. So when i try to get huge file, Jvm throws heap size exception. Do you guys know any ways to solve this problem?
The Java JRE comes with a JAX-WS Provider. This provider has what I would consider a bug. If a SoapHandler is added, either by directly getting the HandlerChain or by using a HandlerResolver, the message, which was correctly created using MTOM, is deconstructed and the attachment(s) are placed inline within the SOAP message. If the attachments are large, this can lead to very poor performance or out of memory errors.
The only solution I have found is to use another JAX-WS provider. From testing, Axis2 seems to work perfectly (although it has a huge number of dependencies). Simply placing another provider on the classpath will cause it to be used. Java looks for a file in META-INF/services named javax.xml.ws.spi.Provider. If this file is found, it will use the Provider specified. The main Axis2 jar will include this file to ensure the Axis2 provider is used. Other Providers may also solve this problem.
Because of this automatic Provider detection, you may find your application does or does not have this problem depending on where it is running. For example, if you deploy an application to IBM WebSphere it already has overridden the default Provider and you will not have this issue. Likely other Application Servers also have overridden the default Provider. If you can get ahold of a copy, IBM also provides a very nice jar, com.ibm.jaxws.thinclient_7.0.0.jar, that has Axis2 packaged in it. This can only be used for standalone applications (those not running in WebSphere), but it is very convenient and resolves this issue.
Related
I've got a SOAP JAXWS WebService here that was running fine with CXF 2.7. It also included the feature that I simply could access it via an URL, for example...
http://localhost:8080/webservices/myService/someMethod?someParameter=1&someOtherParameter=2
...which would result in an XML response. Unfortunately, I had to switch to CXF 3.1.5 (because of compatibility problems with more recent Spring versions) and now this feature seems to be gone, the only answer I get now is...
No binding operation info while invoking unknown method with params
unknown
Has anyone an idea where I can re-enable this feature (while I personally don't need it, some other people accessing the service with their own tools may depend on it)? Perhaps I was missing some dependency when moving to 3.1.5...
Looks like the problem is the URIMappingInterceptor that has been removed from the default chain (and the code, since it was deprecated, see the migration guide) for security reasons. Unfortunate for people who depend on the HTTP Get mapping it did... Of course I could re-introduce it, but there's still the hope that there is a better, security-aware way of doing it...
I inherited a codebase, a chunk of which is a webservice built using the Eclipse generators. The generated code appears to have numerous file paths (for wsdls, etc) which refer to locations on the original developer's box. For example, in a service class's static constructor:
url = new URL(baseUrl, "file:/C:/Users/OldDeveloperName/workspace/ServiceProject/WebContent/WEB-INF/edmo/AXIS-1-4/MainEntityService-1.0.wsdl");
Seems like a bad thing, to my naive eyes. Is this a) OK, or b) fixable? I know I could just edit it now, but there's quite a few service files and it seems like there'd be an easy correction if it's a common problem. I mean, as-is it doesn't even look deployable to me.
Original developer obviously followed the approach to store WSDL locally, which is actually a good practice. Namely, JAX-WS client before execution needs to retrieve WSDL once more from the original location to check additional metadata etc. (it sounds weird, but that's how it works). But, what if original WSDL is not available anymore or the Web service developer updated the WSDL with e.g. new method? Your Web service call would not be executed and that is not probably what you want. Therefore, people started to store WSDL together with their client, to avoid vulnerability on WSDL availability/change.
Is this a) OK, or b) fixable?
It is not OK to store WSDL on local filesystem, and that is where the original developer made the huge mistake. WSDL should be packed together with Web service client (in same JAR) and retrieved directly from the archive. There are several ways how to retrieve WSDL locally, see this tutorial for instructions. One way or another, you will have either edit the WSDL location or completely change the old code :)
References:
Why does JAX-WS clients need WSDL access?
The problem is exactly the same as described here:
Exception java.util.zip.ZipFile.ensureOpenOrZipException with WAS 7
Following the resolution, I changed my application module to 2.4 and it resolved the issue. I did not changed the path of wsdl as mentioned in the resolution. But once the application module is changed, the webservices.xml file is not getting generated. I need the xml file to be generated.
Anyone having any alternative solution to this problem where I do not need to change the application module?
Regards,
The original question you are referring to has two parts. One is about the ZIPException. Since that exception is triggered deep down in the WebSphere code it is unlikely that you will get a solution for that problem here. You should contact IBM support for that. The other part is about memory issues. From my experience with using JAX-WS services deployed on WebSphere (and using WebSphere in general), I can make two recommendations:
The original question says that the problem occurs "after few deployments". This poins to a class loader leak. A class loader leak is a particular kind of memory leak that prevents the old class loader of an application from being garbage collected after a redeployment or restart of the application (for a more detailed description, see here). This can be caused by the application or the server runtime. Experience shows that WebSphere itself has several issues that cause this type of leaks, and IBM is in general not very efficient in solving these issues. I once compiled a list of known WebSphere issues of this type that I have encountered. It is published here. One can see that basically any more or less complex Java EE application will be affected by this type of issue. Therefore you should be prepared for the fact that when redeploying frequently without restarting the server, it will eventually run out of memory.
Note: In defense of IBM it should be said that other application servers don't necessarily perform better in this area.
There is one particular case where JAX-WS services deployed on WebSphere may consume unexpectedly large amounts of memory. This occurs for services that have been developed using the top-down approach (i.e. starting from the WSDL), but that have #WebService annotations that don't refer to the original WSDL. In that case, WebSphere (quite correctly) believes that they are bottom-up services and generates WSDL and XML Schema documents based on the JAX-WS/JAXB2 annotations. These documents are kept in memory and in some cases (especially for complex services) may be significantly larger than the original WSDL and XML Schema documents. I've once seen an application that was consuming 200MB of heap just for that. To avoid this, make sure that when creating top-down JAX-WS services, you package the original WSDL and XML Schema documents in the application and that the service implementations have #WebService annotations that correctly refer to these documents.
I've seen this problem all over the Web, but still haven't found a clear solution that has worked for me. Here's the issue:
I am trying to create a Web service client in Java. The client needs to be a console app that will be placed on a server and automatically run at a certain time interval. The Web service I am trying to consume was written and is hosted by a third party company. The service was written in ASP.NET. The company in question has several services that we hit. All of them are written in ASP.NET. I have never dealt with these services until 2 days ago when I was tasked with consuming 2 of the services and building an Excel spreadsheet from the data. Before I continue, let me describe my development environment. Some of this is relevant, some is not, but I want to include everything:
Windows 7 Professional 32-bit
NetBeans IDE 6.9.1
Java JDK 1.6.0_17
jre6
Glassfish 3 Open Source Full-Platform Release
All software has had all available updates applied
On to the problem. When I added the first Web Service Client to my console app, I was surprised at how smoothly the process went. Most of my experience writing Web Service apps is in .NET. I was able to import the WSDL and NetBeans generated all classes on the first try. Within 5 minutes, I was able to make my first call to the service and was greeted with the expected response, letting me know that my attempt was successful. I then added the second Web Service Client to the console app using the address to the second WSDL I needed. This is where I ran into a major problem.
Upon importing the WSDL, I was alerted to an error by NetBeans stating:
Web Service Client can not be created by JAXWS:wsimport utility.
Reason: undefined element declaration 's:schema'
After abusing Google for the next hour looking for a solution, I finally decided to apply some trial and error. Looking at the Output window in NetBeans, I could see that it was complaining about 3 specific lines. Once I took a look at the WSDL, I could see that those 3 lines were exactly the same, as follows:
<s:element ref="s:schema" />
These 3 lines were found in random places from the top of the WSDL, down to about half-way through. I removed these lines from the WSDL found in the Web Service References folder, leaving the WSDL in the META-INF folder alone. I then did a refresh on the service reference and much to my surprise, NetBeans parsed the WSDL and generated my classes just as before. Great, right? Well, here's where problem #2 comes into play.
Now that I was able to compile my app with no errors, I had to try to hit the service to see if my hack had worked. It did not. Because of another bug in JAXWS, I have to provide the URL to the WSDL in the constructor when creating a service object. This means that the WSDL I fixed is being ignored and the service is now back to using the WSDL that can not be parsed. When I tried to provide the location of WSDL I edited locally within my project, I was greeted with another compilation error stating that I had a NullPointerException. It said that I needed to initialize the object before using it.
I have researched what seems like an infinite amount of topics on this site looking for and trying any solutions that have been provided. I have also tried solutions from all over the Web, all with no luck. If anyone has any advice for me, any tips, tricks, hacks, please let me know. I'm open to any suggestions at this point.
Thanks in advance for any assistance provided.
One-sided contract changes may lead to problems.
Assuming the s prefix refers to the http://www.w3.org/2001/XMLSchema namespace, it looks like your WSDL references XML schema types. JAX-WS is probably unable to resolve this when generating the JAXB bindings.
You can download the XSD from http://www.w3.org/2001/XMLSchema.html; at a minimum, you'll need XMLSchema.xsd, XMLSchema.dtd and datatypes.dtd. Generating Java types from this may require fiddling with your JAXB binding configuration.
Alternatively, it may be easier to just use dynamic JAX-WS client code. You can use a tool like soapUI to create/test sample XML requests.
If you do decide to edit the WSDL, the generated service code should have a constructor of the form Foo_Service(URL, QName) that allows you to provision the WSDL locally (e.g. from your classpath).
The first thing I'd do is try to open it in one of the tools meant for testing SOAP services, like SoapUI. If you have schema not resolving, that is possible there will be pieces of code that you may need that won't be generated as well. I had that happen recently with a vendor supplied "web service", and after much dissembling they "miraculously" found an alternative set of services that worked fine.
You could also try some of the alternatives to Jax-Ws, like CXF or Axis.
How specifically can you use the javax.jws.WebService.wsdlLocation in JBoss 4.2.2? (This is for an EJB3 bean deployed as a web service).
There is some documentation around that it is supported, but what exactly is the format? I have tried an http, I have tried a relative URL. How does JBoss look for it, a URL, something on the classpath of the EJB, something else?
You should take a look at JBWS-2206 and related issues JBWS-1714 and JBWS-1837.
From the information I could gather, JBoss internally uses Metro (the RI) for JAX-WS. I'm not very sure about this, but it appears that Metro reads WSDLs, if provided via the wsdllocation attribute, using the classloader, thereby making META-INF/wsdl of the EJB JAR a safe choice to place WSDLs. The example file in JBWS-2206 would help as a reference.
Update
A thorough overview on how to provide your own WSDL is present in the JBoss forums.
Update #2
The JAX-WS specification, gives a better idea on why this is the case. In the section 5.2.5.3 Use of #WebService(wsdlLocation) and Metadata, one can find the specification stating that
The value of the wsdlLocation annotation element on an endpoint implementation class, if any, MUST
be a relative URL. The document it points to MUST be packaged with the application. Moreover, it MUST
follow the requirements in section 5.2.5.4 below (”Application-specified Service”).
Furthermore, it states that
A JAX-WS implementation MUST patch the location attributes of all wsdl:import and xsd:import
statement in local documents that point to local documents. An implementation MUST NOT patch any
other location attributes.
defining how the generated WSDL should appear.