Using Apache CXF 2.7.7 if I publish a simple "HelloWorld" JAX-WS service and attempt to resolve the WSDL URL in a web browser using: "localhost:8080/service/HelloWorld?wsdl" the WSDL loads in the browser and everything looks great.
If I then add the below annotation which changes the SOAP Binding to 1.2 the WSDL resolution still works but the WSDL doesn't load in the browser, instead a download dialog is shown and the name of the WSDL is missing the file name extension in the download dialog (which is probably why it isn't loading in the browser).
javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING
The same behavior appears with the SOAP12HTTP_MTOM_BINDING
#javax.xml.ws.BindingType (value=javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_MTOM_BINDING)
Functionally everything works fine even with the BindingType annotation defined so this is just a minor annoyance but I'm wondering how I can get the correct WSDL resolution behavior when the default SOAP 1.1 binding is in use.
I posted this issue on the Apache CXF JIRA and it was acknowledged as a defect. It has been fixed and will be included with the Apache CXF 2.7.8 release.
https://issues.apache.org/jira/browse/CXF-5334
Related
I have created a sample project to show my trouble while trying to produce an XML response from my Rest web service.
I use Open JDK 15, Jersey 3.0.2 and Jetty 11.0.0
You can clone and run the project to see my point : https://github.com/dpapin1118/jersey-jetty
Whichever Xml Provider I choose, Jersey ends up picking another provider that is not compatiblé with Xml (or no provider at all).
It looks like if my Resource Config was not taken in account by the Server
ResourceConfig resourceConfig = new ResourceConfig(
EchoControllerXml.class
).packages("lu.isd.jetty.model.echo")
.register(MoxyXmlFeature.class);
and that the
Server server = JettyHttpContainerFactory.createServer(appUri, resourceConfig, false);
was not working.
In the end, calling curl http://localhost:10020/xml/bonjour does not return anything but generate a
java.io.IOException: Unconsumed content
at org.eclipse.jetty.server.HttpInput.consumeAll(HttpInput.java:133)
at org.eclipse.jetty.server.HttpConnection.onCompleted(HttpConnection.java:432)
at org.eclipse.jetty.server.HttpChannel.onCompleted(HttpChannel.java:859)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:384)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:289)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:324)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:106)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:790)
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:912)
at java.base/java.lang.Thread.run(Thread.java:832)
I have managed to use both Json and XML in previous Jersey version by adding the correct maven dependency and register the right provider, but nothing worked with those very recent versions of Jersey, Jetty and Java.
Note that Json has no issue.
Iam using Dynamic Web Project 2.5, Jersey and Tomcat 7.0 to create a Java Restful Webservice. I want to response JSON if someone request data. But i always get the following error from Tomcat:
That my configurations in relation to web.xml and annotations are ok is demonstrated by using xml instead of JSON. Then its working fine:
If i switch MediaType Notation from APPLICATION_XML to APPLICATION_JSON the error is thrown.
Iam using Chrome-Browser and i read that chrome just show a json-string if requested. I hope someone can help me. Thanks in advance.
Seeing from your previous question, you seem to missing a provider for JSON/POJO support. You can see this answer for all the jars and dependencies you need to add to your project.
Note: The linked answer shows 2.17 jars for Jersey, but you are using 2.18. The answer also provides a link where you can download the version you need.
Our application sends file attachment to a web service using SOAP. The service is running on Oracle Service Bus 11g. We are using Spring WS + SAAJ + MTOM on client to send the request.
The application works fine on local and tomcat server, however, when we move the application to weblogic 12c server (war deployed), we see the following error when we hit the service.
BEA-382120 Error: Mixing of XOP/MTOM and attachments is not allowed!
It seems when it is deployed on the WebLogic the message no longer has MTOM enabled.
========================
Some additional information that might be helpful:
Spring WS configuration, libs used:
spring-ws-1.5.8.jar
commons-httpclient-3.1.jar
Thanks in advance.
After more investigation, it seems that weblogic overrides some of the classes or somehow confuses the classpath. In our case it was Saaj implementation. We had to add the saaj-impl-1.3.20.jar into our class-path and it worked. We also upgraded to spring-ws 2.2.0 and set the mtom to enable on the marshaller from the xml file.
You can also add this jar in your setDomainEnv.cmd file of your weblogic folder
set EXT_PRE_CLASSPATH=%DOMAIN_HOME%\lib\saaj-impl-1.3.20.jar
I'm consuming a webservice where the WSDL file contains imports to other wsdl and xsd schemas, e.g:
<import namespace="http://my.api.com/" location="http://other.server.com:8888/context/services/MyService?wsdl=1"/>
which in turn can import other files
<xsd:import namespace="http://my.api.com/" schemaLocation="http://other.server.com:8888/context/services/MyService?xsd=1"/>
The client is generated by cxf with a maven plugin. The main WSDL file is added as a classpath resource. However, at runtime it appears that the client actually needs access to other.server.com:8888 to resolve the WSDL completely. So the question is, does a tool exist for importing and resolving all URLs in a WSDL so that it is not dependent absolute server URLs in other imports in the WSDL, and suitable for including in a client project?
We do not control the WSDL, so we can't change it in the source.
Edit: Looking for a tool that works on Linux
Check the ServiceModel Metadata Utility Tool (Svcutil.exe) from Windows SDK.
svcutil /t:metadata http://service/metadataEndpoint
This tool locates or discovers, one or more related documents that describe a particular XML Web service using the Web Services Description Language (WSDL).
I don't know if I understood your question correctly. I'm having my battles with Jax-ws/SOAP too. :)
If you need to generate the java classes needed to call the webservice you can use Apache CXF. Inside it you have a wsdl2java. You can use it on linux.
Another option in Java SDK, on the bin folder there's the wsimport that you can use it too.
Edit: You can change the final URL at runtime using the Service class created by Apache CXF.
new SomeRandomJaxWSService(new URL(wsdl),new QName(namespace, serviceName))
I have done this on Websphere (re: title of this topic) using wsdl2java for generating wsdl to java mapping xml file.
My endpoint is a generic stateless EJB. The code in EJB is generated by traversing the each wsdl and getting the wsdl operation and stuck it in the generated remote EJB interface.
Each EJB method impl is generic and handles all the services the same.
Used instructions on this doc to do this on WAS: http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/twbs_devwbsjaxrpcwsdl.html
Now, I am asking you all for help if anyone has done something similar in Sun AS 9.1.
Starting from existing WSDL (and xsd) files. Knowing the sole EJB service endpoint implementation for each services are the same, and generating an EAR file (webservices.xml, ejb-jar.xml, etc).
Have struggled with wscompile and alike, but not getting anyware in the same fashion I did for WebSphere.
Thanks for help.
You want to create a WS client which runs under Sun AS? I don't know Sun AS in detail and I don't know the WS libraries it supplies. But you may want to use a public WS library:
Apache Axis 2
Apache CXF
For every library there is documentation which describes how to create a project from WSDL.
You could even use Eclipse to create a project from WSDL for you: File -> New -> Other... -> Web Services -> WSDL. Make sure you have the "WST Web Services" Plugins installed.
I've never used it myself, but I just recently read about the wsdlLocation() attribute of the WebService annotation, which is supposed to map the service to a preexisting WSDL document (not sure if you're even using EJB3, though).