[JBossWS] - Re: Writing a client - no examples for BindingProvider based
by alessio.soldano@jboss.com
The EntityManager injection should work given you're using an EJB3 endpoint. I personally used it:
WS endpoint & EJB SLSB impl:
| @Stateless
| @WebService(name="TestCaricoWS",
| targetNamespace = "http://www.xxx.it/TestCarico",
| serviceName = "TestCaricoWSService")
| @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
| public class TestCaricoSessionBean implements TestCaricoInterface {
|
| @Resource
| private SessionContext ctx;
|
| @PersistenceContext(unitName = "TestCarico")
| private EntityManager manager;
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| @WebMethod(operationName="performTest")
| @Oneway
| public void performTest(@WebParam(name="uffa") Uffa uffa) {
| Query query = manager.createQuery("from TestCarico where cdTestCarico>=:from and cdTestCarico<=:to");
| query.setParameter("from", uffa.getFrom());
| query.setParameter("to", uffa.getTo());
| List<TestCarico> entities = query.getResultList();
| ....
|
Interface:
| @Local
| public interface TestCaricoInterface {
|
| public void performTest(Uffa uffa) throws Exception;
| ....
|
Datasource:
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
|
| <xa-datasource>
| <jndi-name>TestCaricoDatasource</jndi-name>
| <track-connection-by-tx/>
| <isSameRM-override-value>false</isSameRM-override-value>
| <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
| <xa-datasource-property name="URL">jdbc:oracle:thin:@10.10.10.1:1523:MYSID</xa-datasource-property>
| <xa-datasource-property name="User">user</xa-datasource-property>
| <xa-datasource-property name="Password">pwd</xa-datasource-property>
| <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
| <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
| <!-- Checks the Oracle error codes and messages for fatal errors -->
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
| <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
| <no-tx-separate-pools/>
| <min-pool-size>1</min-pool-size>
| <max-pool-size>100</max-pool-size>
| <blocking-timeout-millis>5000</blocking-timeout-millis>
| <idle-timeout-minutes>1</idle-timeout-minutes>
| </xa-datasource>
|
| </datasources>
|
persistence.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence 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"
| version="1.0">
|
| <persistence-unit name="TestCarico">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/TestCaricoDatasource</jta-data-source>
| <properties>
| <property name="hibernate.dialect"
| value="org.hibernate.dialect.HSQLDialect" />
| <property name="hibernate.show_sql" value="true" />
| <property name="jboss.entity.manager.factory.jndi.name"
| value="java:/TestCaricoEntityManagerFactory" />
| </properties>
| </persistence-unit>
| </persistence>
|
Please note that no manual actions with transactions and so on is required.
Hope this helps, anyway for qualified support about EJB3 questions also refer to http://www.jboss.com/index.html?module=bb&op=viewforum&f=221.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4117466#4117466
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4117466
18 years, 3 months
[JBossWS] - Re: Document Literal style
by zeeshan.javeed
Hi,
I have generated the code using WSCONSUME and after modifying existing code, when I try to run the old client I got Null Pointer Exception. I generated the new client using the newly generated wsdl file and the new client works fine.
I debuged more and here is the request send by old client.
| POST /wipe/service HTTP/1.1
|
| Content-Type: text/xml; charset=utf-8
|
| Accept: text/xml, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
|
| Content-Length: 655
|
| SOAPAction: ""
|
| User-Agent: Java/1.5.0_13
|
| Host: 127.0.0.1:8080
|
| Connection: keep-alive
|
|
|
| <?xml version="1.0" encoding="UTF-8"?>
| <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://ips.iplabs.de/types">
| <env:Body>
| <ns0:startSession>
| <TSession_1>
| <clientLogInfo></clientLogInfo>
| <clientName>testJavaClient</clientName>
| <clientVersion>0.5</clientVersion>
| <errorCode>0</errorCode>
| <errorMessage></errorMessage>
| <localeID>de_DE</localeID>
| <opID>20000100</opID>
| <sessionID></sessionID>
| <wipeVersion>1.1</wipeVersion>
| </TSession_1>
| </ns0:startSession>
| </env:Body>
| </env:Envelope>
|
The request generated by the new client is as
| POST /wipe/service?datatype=JBossWSMessage HTTP/1.1
|
| SOAPAction: ""
|
| Content-Type: text/xml; charset=UTF-8
|
| User-Agent: Java/1.5.0_13
|
| Host: 127.0.0.1:8080
|
| Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
|
| Connection: keep-alive
|
| Content-Length: 475
|
|
|
| <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
| <env:Header></env:Header>
| <env:Body>
| <ns1:startSession xmlns:ns1="http://ips.iplabs.de/types">
| <arg0>
| <clientLogInfo></clientLogInfo>
| <clientName>testJavaClient</clientName>
| <clientVersion>0.5</clientVersion>
| <errorCode>0</errorCode>
| <errorMessage></errorMessage>
| <localeID>de_DE</localeID>
| <opID>10000011</opID>
| <sessionID></sessionID>
| <wipeVersion>1.0</wipeVersion>
| </arg0>
| </ns1:startSession>
| </env:Body></env:Envelope
|
|
Any information , what is going wrong here.
The interface file code related to startSession is :
|
| /**
| * This class was generated by the JAX-WS RI.
| * JAX-WS RI 2.1.1-b03-
| * Generated source version: 2.0
| *
| */
| @WebService(name = "Wipe", targetNamespace = "http://ips.iplabs.de/")
| public interface Wipe {
|
|
| /**
| *
| * @param tSession1
| * @return
| * returns de.iplabs.ips.types.TSession
| */
| @WebMethod
| @WebResult(name = "result", targetNamespace = "")
| @RequestWrapper(localName = "startSession", targetNamespace = "http://ips.iplabs.de/types", className = "de.iplabs.ips.types.StartSession")
| @ResponseWrapper(localName = "startSessionResponse", targetNamespace = "http://ips.iplabs.de/types", className = "de.iplabs.ips.types.StartSessionResponse")
| public TSession startSession(
| @WebParam(name = "TSession_1", targetNamespace = "")
| TSession tSession1);
| }
|
|
and the respective implementation is as :
| @WebService(name = "Wipe", targetNamespace = "http://ips.iplabs.de/types")
| public class WipeImpl implements Wipe
| {
|
|
| /**
| *
| * @param tSession1
| * @return
| * returns de.iplabs.ips.types.TSession
| */
| @WebMethod
| public TSession startSession(TSession session)
| {
| if(session != null)
| {
| log.debug("Start session with version: " +
| return getVersion(session).startSession(session);
| }
| else
| {
| log.error("Session is null");
| return null;
| }
| }
|
| }
|
|
Plz guide me, what is going wrong. I have to update server while mainting the compatibility between old client and server.
Regards,
Zeeshan
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4117455#4117455
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4117455
18 years, 3 months