I am trying to deploy a spring-ws SOAP webservice in JBoss 4.2 (JDK 1.6, spring 3.0, spring-ws 2.0). I am using JAXB2 as O/X binding. Setup is fine, beans found and wired, requests can be sent and responses are generated. However, I am getting empty responses. It neither is in a SOAP envelope nor contains my simple UserDetails any content that is assembled on the server.
The correct response would be:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:UserDetails xmlns:ns2="http://a.dol.com/schemas">
<ns2:name>John</ns2:name>
<ns2:lastname>PerX</ns2:lastname>
</ns2:UserDetails>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But I just get something like:
<Envelope>
<Header/>
<Body>
<ns2:UserDetails xmlns:ns2="http://a.dol.com/schemas"/>
</Body>
</Envelope>
After searching google, I found the following code to be added:
<beans>
<!-- Big magic hack to fix the broken SAAJ in JBoss
See http://static.springsource.org/spring-ws/sites/1.5/faq.html#saaj-jboss -->
<bean id="messageFactory">
<property name="messageFactory">
<!-- This is the Java 6 variant of this fix! Note the "internal" package missing in the spring-ws FAQ. -->
<bean class="com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/>
<property>
<bean/>
</beans>
But this also doesnt help, I get the folloiwng error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'messageFactory' defined in ServletContext resource...
Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError...
Caused by: java.lang.IllegalArgumentException: com.sun.xml.messaging.saaj.soap.LocalStrings != com.sun.xml.internal.messaging.saaj.soap.LocalStrings
Any hints appreciated.
Updated
Updating the run.bat for JBoss with the following does fix the problem, but is this the correct way of doing it??
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPConnectionFactory=com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
Replace the spring snippet with
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<property name="messageFactory">
<bean class="com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/>
</property>
</bean>
You have left out the fully qualified classname in the messageFactory bean definition.
This should work then without the startup options.
Updating the run.bat for JBoss with the following does fix the problem:
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPConnectionFactory=com.sun.xml.messaging.saaj.client.p2p.HttpSOAPConnectionFactory
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl
set JAVA_OPTS=%JAVA_OPTS% -Djavax.xml.soap.SOAPFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl
Related
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)
I use version 3.8 (3.8.3) .
I basically want to host my wsdl in a different location other than http://{serviceurl}?wsdl like http://{serviceurl}/my-great-service.wsdl
At the following mule doc
https://docs.mulesoft.com/mule-user-guide/v/3.8/wsdl-connectors
it says that you can specify the _wsdlLocation_ property of the CXF endpoint as follows
<endpoint address="wsdl-cxf:http://localhost:8080/book/services/BookService?method=getBooks">
<properties>
<property name="wsdlLocation" value="file:///c:/BookService.wsdl"/>
</properties>
</endpoint>
But where to put this in the mule xml ?
To the root of the file <mule> here </mule> or to <flow> here </flow> or to the <cxf:proxy-service> here </cxf:proxy-service>
The mule documentation is so limited and lock of examples.
Any reason why you are using the cxf connector instead of the web service consumer?
https://docs.mulesoft.com/mule-user-guide/v/3.8/web-service-consumer
All the global configuration elements are specified after the <mule> tag and before the <flow> elements.
Example with web service consumer below:
<mule ......>
<ws:consumer-config name="Web_Service_Consumer" service="ServiceService"
port="ServicePort" serviceAddress="addresUrl"
wsdlLocation="wsdl location" doc:name="Web Service Consumer"/>
<flow>...</flow>
</mule>
If for any reason you want to use the cxf connector, is the same but using the cxf connector
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.
Hello!
I'm trying to learn some Apache Camel and Apache CXF and of course I've ran into some problems.
What I'm trying to do:
Send timed SOAP messages from ESB to some web service, wait for the reponse from the web service and process it. I'm using Apache ServiceMix!.
What I've done:
Implemented a WSDL file with two operations PingOutput (what I'm sending) and PingInput (what I want to receive from the WS).
Implemented a CXF Endpoint (http://127.0.0.1:8090/ping_ws is a WS mocked with SoapUI):
<cxf:cxfEndpoint address="http://127.0.0.1:8090/ping_ws"
id="Ping_Mocked_WS" wsdlURL="ping.wsdl">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD" />
</cxf:properties>
</cxf:cxfEndpoint>
Implemented a Camel route:
<camelContext xmlns="http://camel.apache.org/schema/spring" streamCache="true">
<route id="ping-ws">
<from uri="timer://ping_timer?fixedRate=true&period=10000"/>
<bean ref="PingBean" method="createPingRequest" />
<to uri="cxf:bean:Ping_Mocked_WS"/>
<bean ref="PingBean" method="processPingResponse" />
</route>
</camelContext>
What I do not understand:
Why the <bean ref="PingBean" method="processPingResponse" /> gets the correct response from SoapUI (the PingOutput operation defined in WSDL)?
Is this the correct way to achieve my goal? And by this way I mean with one single route?
The codes work correctly, I might have some typos here, please do not mind them.
Thanks!
Ad 1)
Likely because the type defined in the method signature of the processPingResponse method. Camel uses bean parameter binding, and based on the type, it uses its type converter to convert to the given type.
And as the payload is a SOAP response in XML it can use JAXB to convert from XML to the type from the method signature.
To do so it uses camel-jaxb which ServiceMix comes with out of the box.
Ad2)
The route works. What it is you want to do differently?
I am developing webservice using CXF. I use HTTP binding so according to http://www.w3.org/TR/wsdl#_soap:operation soapaction is mandatory for this type of transport.
The problem is that I want to deploy the same application for test and production server. I would like to do it without rebuilding application or keeping external WSDL files, which will add one more thing on maintenance list.
I had the same problem with location, but that one was trivial to solve. I used publishedEndpointUrl in endpoint configuration to set proper value. The value is retrieved during initialization of application from external property file, which I placed on classpath tomcat/common/classes .
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation="http://www.springframework.org/schema/beans 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="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:ws.properties</value>
</list>
</property>
</bean>
<jaxws:endpoint xmlns:tns="http://example.org/ds" id="ds" implementor="org.example.Ds" wsdlLocation="wsdl/ds.wsdl" endpointName="tns:dsSOAP" serviceName="tns:Ds" address="/dsSOAP" publishedEndpointUrl="${publishedEndpointUrl}">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature" />
</jaxws:features>
</jaxws:endpoint>
</beans>
I would like to achieve the same functionality for soapaction. The value for this attribute should be not relative URI. So for test it should be:
<soap:operation soapAction="https://test.example.org/dsSOAP/operation1" />
and for production
<soap:operation soapAction="https://example.org/dsSOAP/operation1" />
any idea how to achieve this?
You dont need to specify an absolute URL, you dont need either to specify a URL. "operation1" would be enough. See some official examples at http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383528
Linking the soap action with the environment the instance is running is not a "best practice".