Weblogic Workmanagers and JAX-WS webservices - web-services

is it possible to manage Jax-WS annotated Webservices in Weblogic WorkManagers (at less WLS 10.3.4) as we can do for Servlets or EJBs ?

Yes!
If you have a global Work Manager you can try that in your weblogic.xml:
<?xml version="1.0" encoding="UTF-8"?><wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.3/weblogic-web-app.xsd">
<wls:weblogic-version>10.3.6</wls:weblogic-version>
<wls:context-root>StuckThreadWebProject</wls:context-root>
<wls:wl-dispatch-policy>wm/NoStuckWorkManager</wls:wl-dispatch-policy>
</wls:weblogic-web-app>
Otherwise:
<?xml version="1.0" encoding="UTF-8"?><wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.3/weblogic-web-app.xsd">
<wls:weblogic-version>10.3.6</wls:weblogic-version>
<wls:context-root>StuckThreadWebProject</wls:context-root>
<wls:work-manager>
<wls:name>wm/NoStuckWorkManager</wls:name>
<wls:ignore-stuck-threads>true</wls:ignore-stuck-threads>
</wls:work-manager>
<wls:wl-dispatch-policy>wm/NoStuckWorkManager</wls:wl-dispatch-policy>
</wls:weblogic-web-app>
Replace <wls:work-manager> content as you wish.

Related

how to test a data source-based and websphere application using JUnit and IBM Rational Application Developer?

I have a package of many JAX-WS web services that run in WebSphere 7 where I had configured a data-source to a DB2 database including the JAAS authentication under an alias.
Now, i just want to test the logic of my DAOs, where -of course- I have an entity manager. So, I created an application client project, partially guided by this tutorial http://www.ibm.com/developerworks/rational/library/08/0219_jadhav/, where I have :
an application-client.xml
<?xml version="1.0" encoding="UTF-8"?>
<application-client version="5"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application-client_5.xsd" metadata-complete="false">
<display-name>ServiciosAcademicoTests</display-name>
<resource-ref>
<res-ref-name>ServiciosAcademicoTests</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
a ibm-application-client-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<application-client-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-client-bnd_1_0.xsd" version="1.0">
<resource-ref name="ServiciosAcademicoTests" binding-name="java:comp/env/jdbc/MyDB">
</resource-ref>
</application-client-bnd>
When I run my test, it returns the following error "Null userid is not supported." :
<openjpa-1.2.1- (...) fatal general error> org.apache.openjpa.persistence.PersistenceException: **Null userid is not supported.** ERRORCODE=-4461
I tried specifying and authentication in the ibm-application-client-bnd.xml but I'm still getting the same error :
<?xml version="1.0" encoding="UTF-8"?>
<application-client-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-client-bnd_1_0.xsd"
version="1.0">
<resource-ref name="ServiciosAcademicoTests" binding-name="java:comp/env/jdbc/MyDB">
<authentication-alias name="dmfloresNode01/XXX "/>
</resource-ref>
Just in case, my unit test is this :
public class CursosTest extends TestCase {
ICursoDAO cursoDAO; // From another project
Integer idAlumno = 123456;
String usuarioPortal = "xxx";
public void testCursosLlevados() throws Exception {
cursoDAO = new CursoDAO();
List<CursoLlevadoVO> lstCursos = cursoDAO
.obtenerCursosLlevadosPorAlumno(idAlumno, usuarioPortal);
if (lstCursos != null) {
for (CursoLlevadoVO cursoLlevadoVO : lstCursos) {
System.out.println(cursoLlevadoVO.getNombre());
}
}
assertNotNull(lstCursos);
}
}
I detected that the problem happen when the entitymanager is created :
entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
entityManager = entityManagerFactory.createEntityManager(); // <-- here
Could you help me, please ? two days looking for a solution :( .
UPDATE :
I think that my application-client even isn't querying the data source, because I changed the jdbc/MyDB to jdbc/XXX and the problem is the same (http://www-01.ibm.com/support/docview.wss?uid=swg21596108 , I'm not getting the "Could not lookup datasource named" message but it could be a cause). Also I tried to deactivate the authentication to the data source in the administrative console of Websphere, but I'm getting same results.
This is my persistence.xml file on the project of webservices (that runs fine, the problem is my application-client that is using a DAO class just for testing purposes, not for testing webservice just in case) :
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="ServiciosAcademico">
<jta-data-source>jdbc/MyDB</jta-data-source>
<class>...</class>
<properties>
<property name="openjpa.jdbc.Schema" value="XXX"/>
</properties>
</persistence-unit>
. This is my data source on websphere, it's under a certain scope :
Day 3 :
Probably, when I remove the alias for the data source I get the same message, so the application-client could be ok about connecting to the data source, but this isn't using any authorization method.
Thanks for your help. I'm a novice of WebSphere.

how to config jax-ws Handler in Spring?

I according jax-ws API integration jax-ws with Spring ,but I get an exception at my webservice project,here is API site :http://jax-ws-commons.java.net/spring/ ,I have same config xml in my project,but i get an exception is below:
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'handlers' is not allowed to appear in element 'ws:service'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
who can give me solution?
The example given is wrong and not valid with regard to the schema. handlers is not an attribute, but a nested element. Use it like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
xmlns:ws="http://jax-ws.dev.java.net/spring/core"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://jax-ws.dev.java.net/spring/servlet http://jax-ws.dev.java.net/spring/servlet.xsd http://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd">
<wss:binding url="/services/demo">
<wss:service>
<ws:service bean="#demoEndpoint">
<ws:handlers>
<ref bean="demoHandler"/>
</ws:handlers>
</ws:service>
</wss:service>
</wss:binding>
</bean>

SOAP Client request with Grails

I try to create a payment system with SOAP for ipayment (Germany) and in its documentation it is described that with the following SOAP request I might get the response shown in second code example.
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<capture>
<accountData>
<accountId>99999</accountId>
<trxuserId>99999</trxuserId>
<trxpassword>0</trxpassword>
<adminactionpassword>
5cfgRT34xsdedtFLdfHxj7tfwx24fe</adminactionpassword>
</accountData>
<origTrxNumber>1-25949395</origTrxNumber>
<transactionData>
<trxAmount>119</trxAmount>
<trxCurrency>EUR</trxCurrency>
</transactionData>
</capture>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
And example response from server is
<?xml version="1.0" encoding="ISO-8859-1"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<ns1:captureResponse
xmlns:ns1="https://ipayment.de/service_v3/binding">
<ipaymentReturn>
<status>SUCCESS</status>
<successDetails>
<retTransDate>25.07.08</retTransDate>
<retTransTime>17:08:08</retTransTime>
<retTrxNumber>1-25949407</retTrxNumber>
<retAuthCode></retAuthCode>
</successDetails>
<addressData>
<addrStreet>Ernst-Frey-Str. 9</addrStreet>
<addrCity>Karlsruhe</addrCity>
<addrZip>76135</addrZip>
<addrCountry>DE</addrCountry>
</addressData>
<addresscheckResult>UNCHECKED</addresscheckResult>
<paymentMethod>VisaCard</paymentMethod>
<trxPaymentDataCountry>US</trxPaymentDataCountry>
</ipaymentReturn>
</ns1:captureResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But I have no idea how to create the request as shown with grails. I try to use Spring WS plugin but the sample codes in documentation doesn't help at all. Do you know any source for some examples or any idea? WSDL schema can be found at https://ipayment.de/service/3.0/?wsdl
Thanks.
If cookies are not needed for authentication to the WS (and they shouldn't :-) ), groovy-wslite is a nice library to use to create SOAP request.
Another method is to use HTTPBuilder which allows you to create tour exact requests and handle cookies if needed (You can do that with wslite, but with a bit more work)
If you are scripting, a tip could be to use curl (if you have that available) directly from groovy. It's pretty powerful, easy to handle and you can do it in a one-liner.
Eg:
"curl -d \"${payload}\" -H \"Content-Type: text/xml\" ${wsUrl}".execute.text
Where the payload is the request(including the soap-envelope).

Spring WS tutorial: no declarationcan be found for element 'context:component-scan' error

I'm following step-by-step (basically copying and pasting stuff) this spring-ws tutorial and I just hit a wall when configuring the spring-ws-servlet.xml as below:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd">
<context:component-scan base-package="com.mycompany.hr"/>
<sws:annotation-driven/>
</beans>
Adding the following line:
<context:component-scan base-package="com.mycompany.hr"/>
make STS starts yelling at me that:
cvc-complex-type.2.4.c: The matching wildcard is strict,
but no declarationcan be found for element 'context:component-scan'.
I don't know how to proceed..
You need to add:
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
to the schemaLocation.

spring / metro / webservice problem

we try to use spring with metro stack to implement webservices.
The setup seems to be ok, but we get an error in the applicationContext.xml
cvc-complex-type.2.4.c: The matching
wildcard is strict, but no declaration
can be found for element
'wss:binding'.
I think that the published examples are out of date and that, for Spring 3, the binding has to be defined in a different way.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:ws="http://jax-ws.java.net/spring/core"
xmlns:wss="http://jax-ws.java.net/spring/servlet"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<wss:binding url="/ws">
<wss:service>
<ws:service bean="#webService"/>
</wss:service>
</wss:binding>
<!-- this bean implements web service methods -->
<bean id="webService" class="com.test.TestService"/>
</beans>
How do I have to configure the binding, or where can I find a description.
For a start, you seem to be missing this in your schemaLocation:
http://jax-ws.java.net/spring/core http://jax-ws.java.net/spring/core.xsd
http://jax-ws.java.net/spring/servlet http://jax-ws.java.net/spring/servlet.xsd
(more here, but I guess you've seen it already)