Spring and Jax-WS : where are xsd schema? - web-services

In spring file applicationConfig.xml, JAX-WS integration need some specific schemas.
I recently successfully use these declarations :
https://jax-ws.dev.java.net/spring/core.xsd
https jax-ws.dev.java.net/spring/servlet.xsd
[I must remove all url (except one) because it's my first question]
The file begins with those declarations :
<beans xmlns="http www.springframework.org/schema/beans"
xmlns:xsi="http www.w3.org/2001/XMLSchema-instance" xmlns:aop="http www.springframework.org/schema/aop"
xmlns:tx="http www.springframework.org/schema/tx" xmlns:context="http www.springframework.org/schema/context"
xmlns:ws="http jax-ws.dev.java.net/spring/core" xmlns:wss="http jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="http www.springframework.org/schema/beans http www.springframework.org/schema/beans/spring-beans.xsd
http www.springframework.org/schema/aop http www.springframework.org/schema/aop/spring-aop.xsd
http www.springframework.org/schema/tx http www.springframework.org/schema/tx/spring-tx.xsd
http www.springframework.org/schema/context http www.springframework.org/schema/context/spring-context.xsd
http jax-ws.dev.java.net/spring/core https jax-ws.dev.java.net/spring/core.xsd
http jax-ws.dev.java.net/spring/servlet https jax-ws.dev.java.net/spring/servlet.xsd">
(...)
<ws:service id="myService" bean="#myWS" />
<wss:binding url="/services/myws" service="#myService" />
Now, a migration occurs for website jax-ws.dev.java.net. These files are not found and I have some errors under Tomcat and Eclipse :
org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'https://jax-ws.dev.java.net/spring/core.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not .
Is there a solution or something to prevent this error ?
Thanks

Finaly I extract XSD from jaxws-spring-1.8.jar (lib for jax-ws to work with Spring).
I put these XSD under WEB-INF directory, just near applicationContext.xml.
I modify declaration of schema in this file with :
http://jax-ws.dev.java.net/spring/core classpath:spring-jax-ws-core.xsd
http://jax-ws.dev.java.net/spring/servlet classpath:spring-jax-ws-servlet.xsd
I have seen the solution here :
Spring schemaLocation fails when there is no internet connection

I suppose you're using maven for building? Try adding the dependency to the pom.xml
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.1-1</version>
</dependency>
If you're not using maven, make sure you have jax-ws libs on your classpath.
http://java.net/projects/jax-ws

You don't need to extract the XSD from the jaxws-spring jar.
You just need to make sure the URL you use corresponds to that in the META-INF/spring.schemas file in the jar
They are defined as follows:
http\://jax-ws.dev.java.net/spring/core.xsd=spring-jax-ws-core.xsd
http\://jax-ws.dev.java.net/spring/servlet.xsd=spring-jax-ws-servlet.xsd
http\://jax-ws.dev.java.net/spring/local-transport.xsd=spring-jax-ws-local-transport.xsd
Think you just need to replace https with http. E.g:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd
http://jax-ws.dev.java.net/spring/servlet http://jax-ws.dev.java.net/spring/servlet.xsd>
For more info on spring.schemas, see here

Related

Can`t enable WS-SecurityPolice with CXF in Web Service

It`s my first project with CXF and Web Services,using Tomcat as a servlet container and my first question in StackOverflow too,so be patient with me....;-)
I'm using :
Tomcat 9 (standalone and integrated with Eclipse).
CXF (3.2.0)
JDK 1.8
Windows 7
**The problem:**WS-SecurityPolicy not enabled/ not working in the server side.
WS-SecurityPolicy is implemented in the wsdl file of the web service and the policy seems working fine,because in the client side the SOAP output message body is signed.
The problem I'm stuck is in the server side,none of the policies are applied in response.
The first issue I had was with the SOAP header "must understand=1",the server does not recognize the security headers and throws an exception.
My suspect was that the web service is not applying the policy,then to avoid the exception of the header I put a handler that does nothing whith it.
Now the server response the SOAP message but in clear form (unsigned, without the BinarySecurityTolen and other stuff),my suspect was true,the policy is not working.
I think the porblem is a misconfiguration of CXF files...
The cxf bean configuration of the web service is loaded during Tomcat's startup.
INFO: Creating Service {http://ole/wsTransaccion}WsTransaccionService from WSDL: wsdl/wsTransaccion.wsdl
....
....
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/cxf-wsTransaccion.xml]
The cxf-wsTransaccion.xml file contains:
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="myPasswordCallback"
class="implementacion.ServerKeystorePasswordCallback" />
<jaxws:endpoint xmlns:tns="http://ole/wsTransaccion" id="wsTransaccion"
implementor="implementacion.WsTransaccionImpl"
wsdlLocation="wsdl/wsTransaccion,wsdl" endpointName="tns:WsTransaccionPort"
serviceName="tns:WsTransaccionService" address="/WsTransaccionPort">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
<jaxws:properties>
<entry key="security.callback-handler">
<ref bean="myPasswordCallback"/>
</entry>
<entry key="security.encryption.properties" value="keystore.properties"/>
<entry key="security.signature.properties" value="keystore.properties"/>
<entry key="ws-security.encryption.username" value="useReqSigCert"/>
</jaxws:properties>
</jaxws:endpoint>
I think the problem coluld be in the location of the file keystore.properties, although no exception is thrown (like a java.io.FileNotFoundException) if not exists..
All examples I saw were Maven's projects ,but this is NOT A MAVEN project so I haven't the folder "resources" where properties files and keystore are placed.
I don't know the right place of keystore.properties, i think must be in the classpath ,then i put it in a package named resources with the keystore together.
The content of keystore.properties:
>org.apache.wss4j.crypto.provider=org.apache.ws.security.components.crypto.Merlin
>org.apache.wss4j.crypto.merlin.keystore.file=server.p12
>org.apache.wss4j.crypto.merlin.keystore.type=PKCS12
>org.apache.wss4j.crypto.merlin.keystore.alias=server
>org.apache.wss4j.crypto.merlin.keystore.password=xxxxxx<br/>
Other possibility is that org.apache.wss4j.crypto.merlin.keystore.file=server.p12 is not in the right place too, although is in the same place like keystore.properties
Any suggestion would be very appreciated.
Thanks very much!!!.
The problem was here:
Tomcat console:
"WARNING: Resource classpath:./resources/policyBinding.xml was not found in the classloaders."Although policyBinding.xml is in the classpath is not properly loaded due to the following annotation in the interface of the web service:
#Policy(uri = "./resources policyBinding.xml",placement=Policy.Placement.DEFAULT)
Thank you to Alfredo (WS-Security Policy node not being generated in Apache CXF with Spring and custom context file
) i figured it out the right syntax:
#Policy(uri = "classpath:policyBinding.xml",placement=Policy.Placement.DEFAULT)

Need IBM Websphere jax ws webservices.xml and web.xml file

I don't have the sample webservices.xml and web.xml file. Can some one help by providing a complete example? I'm using Web Sphere JAX-WS implementation. WAS 7.x version. JDK 1.6.
I tried setting "UseWSFEP61ScanPolicy: true" in MANIFEST.MF file, for automated annotation scanning (instead of webservices.xml and web.xml file usage), but it is working first time, and after deploying a dynamic patch it doesn' works. The services listed under "services" category of IBM Console is having question mark instead of green arrow. Also some times the services even not listed in "services" category.
I'm using web module version 2.3, so i've to enable automated scanning. I'm not using EJB for web service.
I've decided to use webservices.xml and web.xml due to not much help in annotation scanning. I hope for webservices.xml and web.xml not need to install and reinstall the application EAR in WebSphere. In the case of annotation scanning reinstall is needed.
PLEASE IBM WEB SITE DOESN'T HELP MUCH!!!
Here's a web.xml I've used. Since it's "empty", the default rules for mapping annotated webservice classes to URL's apply, approximately, URL = name of class + "Service".
webservices.xml is not needed.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">
<display-name>wsfp_hello_svc</display-name>
</web-app>
Check SystemOut.log to find the URL of your service, look for something like this:
WSWS7037I: The /HelloService URL pattern was configured for the example.HelloDelegate servlet
If you don't like the default mappings, then you can map your webservice class to a different URL in web.xml just like you would do with a servlet.

How to override wsdl soap-address within the ear under wildfly?

We have an ear application, that contains some WS endpoints. I have to deploy to the target server but I have to override the WSDL soap-address tag. The solution we use our local testbed is following this instruction: https://stackoverflow.com/a/23491951 That works perfectly. (server is wildfly 8.2)
However we cannot use this solution anymore on production server ("just because").
I found, that there is a jboss-webservices.xml, that should override the wsdl's <soap-address> tag without changing the standalone.xml / domain.xml's webservices subsystem settings.
But it is not working for me. My jboss-webservices.xml:
<?xml version="1.1" encoding="UTF-8"?>
<webservices version="1.2"
xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss_webservices_1_0.xsd">
<property>
<name>wsdl.soapAddress.rewrite.modify-wsdl-address</name>
<value>true</value>
</property>
<property>
<name>wsdl.soapAddress.rewrite.wsdl-host</name>
<value>somedomain.com</value>
</property>
</webservices>
These instructions are followed:
https://docs.jboss.org/author/display/JBWS/Published+WSDL+customization
https://docs.jboss.org/author/display/JBWS/Advanced+User+Guide
I place jboss-webservices.xml both two places referred by the documentation:
META-INF/jboss-webservices.xml for EJB webservice deployments
WEB-INF/jboss-webservices.xml for POJO webservice deployments and EJB webservice endpoints bundled in war archives
Non of them works.
The related log snippet:
11:50:43,502 INFO [org.jboss.ws.cxf.metadata] (MSC service thread 1-2) JBWS024061: Adding service endpoint metadata: id=ABCServicePortType
address=http://localhost:8180/abc-web/ABCServicePortType
implementor=example.service.v1.impl.ABCServicePortTypeImpl
serviceName={http://example.com/ns/mod/ws/ABCService/v1}ABCService
portName={http://example.com/ns/mod/ws/ABCService/v1}ABCServicePortTypeImplPort
annotationWsdlLocation=null
wsdlLocationOverride=null
mtomEnabled=false
My questions: May I miss something? Is there any other way to override soap-address?
Thanks in advance.
The properties that you provided in jboss-webservices.xml works but with a higher version of WildFly than you are using in your server (since WildFly 9). See webservices section of release notes for WildFly 9:
http://wildfly.org/news/2015/07/02/WildFly9-Final-Released/
It looks that before WildFly 9 release standalone.xml is the only one place to customize WSDL generation.

Mule soap Proxy wsdl fails at relative path resolution of xsd

I have a WSDL and a Mule SOAP proxy web service using the MuleSoft XML Only SOAP Web Service example.
My application is working fine but if i enable validation i have one issue: When the XSD is stored anywhere other than the root of the project, it will not resolve.
I created folders of service and xsd inside /src/main/resources,
however when the service is invoked I receive the following error:
connector.http.mule.default.receiver.02] org.apache.cxf.wstx_msv_validation.ResolvingGrammarReaderController: D:\Developer\Global\BODs\GetListSalesOrder.xsd (The system cannot find the path specified)
java.io.FileNotFoundException: D:\Developer\Global\BODs\GetListSalesOrder.xsd (The system cannot find the path)
This is my mule flow..
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="test" doc:name="HTTP"/>
<cxf:proxy-service port="SyncSalesOrderBinding" namespace="http://www.cg.com/services/oagis/salesOrder" service="SyncSalesOrderService" validationEnabled="true" payload="body" wsdlLocation="services/WebServices/WSDL/SalesOrder.wsdl" doc:name="CXF">
<cxf:schemaLocations>
<cxf:schemaLocation>services/Developer/Global/BODs/GetListSalesOrder.xsd</cxf:schemaLocation>
</cxf:schemaLocations>
</cxf:proxy-service>
<logger message="Success" level="INFO" doc:name="Logger"/>
If your XSD file is imported in your wsdl file the following Code is fine :-
<cxf:proxy-service port="SyncSalesOrderBinding" namespace="http://www.cg.com/services/oagis/salesOrder" service="SyncSalesOrderService" validationEnabled="true" payload="body" wsdlLocation="services/WebServices/WSDL/SalesOrder.wsdl" doc:name="CXF"/>
You don't need to mention your XSD file in CXF component .. it will validate
If you still face any issues then there is patch available here : https://www.mulesoft.org/jira/browse/MULE-5963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
.... Please you replace your jar with the one attached to the JIRA ... It will work definately

How to deploy Apache CXF webservice to Glassfish

I have a web service client generated and built with Apache CXF. Next I have JAX-RS Jersey application in which I want to call methods from that webservice. When I try to deploy this simple project to Glassfish 4.0 server I get this exception:
Exception while deploying the app [pelijee] :
The lifecycle method [finalizeConfig] must not throw a checked exception.
Related annotation information: annotation [#javax.annotation.PostConstruct()] on annotated element [public void org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.finalizeConfig() throws java.security.GeneralSecurityException,java.io.IOException] of type [METHOD]. Please see server.log for more details.
Command deploy failed.
The only one CXF dependency I have in this project is:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<version>2.7.6</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
Is there any other CXF library compatible with JSR 250?
Thank you
One of the challenges of Glassfish is that the full server profile comes packaged with Metro for JAX-WS web services and Jersey for JAX-RS rest services. It is recommended to configure the classloader through a sun-web.xml file included in the WEB-INF folder of your WAR. It should include the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC
'-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN'
'http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd'>
<sun-web-app>
<class-loader delegate="false"/>
</sun-web-app>
In the past, I have found that occasionally I still have problems with deployment; therefore, I have actually removed the Metro and Jersey features altogether from the Glassfish server profile. Here is some more information about deployment.
http://cxf.apache.org/docs/application-server-specific-configuration-guide.html
One additional thing I noticed is that you posted a log message which included the Jetty transport. This means you are running the Jetty HTTP server and running the Glassfish HTTP server. I would suggest just using Glassfish as the web server and using the CXF servlet transport instead.