It also works without specifying the WSDL.
On Fri, Jun 14, 2013 at 2:33 PM, Thomas Manson <[email protected]>wrote: > Hi Daniel, > > Thanks, it works now :) > > with just the following modifications: > > String endpoint = " > http://amxbpm:8080/amxbpm/WorkListService"; > > int timeout = 60; > String username = "tibco-admin"; > final String password = "secret"; > > > JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); > factory.setServiceClass(WorkListService.class); > factory.setAddress(endpoint); > > factory.setWsdlLocation("D:/ARTIC/SOURCE/artic/trunk/webapp/src/main/webapp/WSDL/brm.wsdl"); > factory.setServiceName(new QName("http://services.brm.n2.tibco.com > ","WorkListService")); > > WorkListService workListService = (WorkListService) > factory.create(); > > > > > Regards, > Thomas. > > > On Fri, Jun 14, 2013 at 2:04 PM, Thomas Manson <[email protected] > > wrote: > >> Hi Daniel, >> >> thanks for the help, I'll change this, any pointer to some sample or >> documentation ? >> >> Do I really need to specify a wsdl location, even if the client has >> been already generated ? >> >> I don't know if you remember, but for the 2.6.1-SNAPSHOT you did >> implement the validate none option to help for the client generation. >> So the client generation is not easy. I just wonder if it will try to >> autogenerate the client if I specify the wsdl location ? >> >> Regards, >> Thomas. >> >> >> >> >> >> On Fri, Jun 14, 2013 at 1:50 PM, Daniel Kulp <[email protected]> wrote: >> >>> >>> >>> > ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); >>> > factory.setServiceClass(WorkListService.class); >>> > factory.setAddress(endpoint); >>> > factory.setServiceName(new QName("http://api.brm.n2.tibco.com >>> > ","WorkListService_EP")); >>> > WorkListService workListService = (WorkListService) >>> > factory.create(); >>> > >>> > Client client = ClientProxy.getClient(workListService); >>> >>> >>> You are using the simple frontend, not the jaxws frontend. Thus, any of >>> the things like the "action" defined in the annotations would not be picked >>> up. You are also not setting the wsdl location, thus, it cannot read them >>> from the wsdl. Thus, the empty action. >>> >>> I'd suggest setting the wsdlLocation as well as flipping to using the >>> JaxWsProxyFactoryBean instead. >>> >>> Dan >>> >>> >>> >>> On Jun 14, 2013, at 5:16 AM, Thomas Manson <[email protected]> >>> wrote: >>> >>> > Hi, >>> > >>> > I've generated my WSDL client with CXF 2.7.0 (from 2.7.1 I get a NPE >>> at >>> > generation time, didn't find a workaround). >>> > >>> > When I use the client I get a NPE on the server side, while with >>> SOAPUI >>> > it's ok. >>> > >>> > I used TCPMon to compare SOAPUI and CXF soap request and I can see >>> that >>> > CXF client do not send the SOAPaction. >>> > >>> > >>> > Questions : >>> > >>> > - What should I do to have CXF client send the SAOPAction ? >>> > - SAOPUI uses UsernameToken-9, CXF uses UsernameToken-1. I didn't >>> find a >>> > way to use the-9 version. what's the difference ? >>> > - SAOPUI add timestamp and nonce something... How can I do the same >>> with >>> > CXF ? Is it necessary ? >>> > >>> > >>> > >>> > >>> > CXF Request : >>> > >>> > <!-- >>> > >>> > POST /*amxbpm*/WorkListService HTTP/1.1 >>> > >>> > Content-Type: text/*xml*; *charset*=UTF-8 >>> > >>> > Accept: */* >>> > >>> > SOAPAction: "" >>> > >>> > User-Agent: *Apache* CXF 2.7.5 >>> > >>> > Cache-Control: no-cache >>> > >>> > *Pragma*: no-cache >>> > >>> > Host: xivertbid05.ermont.infra.sncf.fr:8888 >>> > >>> > Connection: keep-alive >>> > >>> > Content-Length: 1090 >>> > >>> > --> >>> > >>> > <soap:Envelope xmlns:soap=*"http://schemas.xmlsoap.org/soap/envelope/ >>> "*> >>> > >>> > <SOAP-ENV:Header xmlns:SOAP-ENV=*" >>> > http://schemas.xmlsoap.org/soap/envelope/"*> >>> > >>> > <wsse:Security >>> > >>> > xmlns:wsse=*" >>> > >>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd >>> > "* >>> > >>> > xmlns:wsu=*" >>> > >>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd >>> > "* >>> > >>> > soap:mustUnderstand=*"1"*> >>> > >>> > <wsse:UsernameToken wsu:Id=*"UsernameToken-1"*> >>> > >>> > >>> <wsse:Username>*tibco*-*admin*</wsse:Username> >>> > >>> > <wsse:Password >>> > >>> > Type=*" >>> > >>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText >>> > "*>secret</wsse:Password> >>> > >>> > </wsse:UsernameToken> >>> > >>> > </wsse:Security> >>> > >>> > </SOAP-ENV:Header> >>> > >>> > <soap:Body> >>> > >>> > <ns1:getWorkListItems xmlns:ns1=*" >>> http://api.brm.n2.tibco.com"* >>> >> >>> > >>> > <ns1:getWorkListItems xmlns=*""* >>> > >>> > xmlns:ns3=*" >>> http://exception.api.brm.n2.tibco.com >>> > "* xmlns:ns4=*"http://exception.api.common.n2.tibco.com"* >>> > >>> > getTotalCount=*"true"* numberOfItems=*"10"* >>> > startPosition=*"0"*> >>> > >>> > <entityID entity-type=*"RESOURCE"* guid=* >>> > "tibco-admin"* >>> > >>> > model-version=*"-1"* /> >>> > >>> > <orderFilterCriteria /> >>> > >>> > </ns1:getWorkListItems> >>> > >>> > </ns1:getWorkListItems> >>> > >>> > </soap:Body> >>> > >>> > </soap:Envelope> >>> > >>> > >>> > SOAPUI Request >>> > >>> > <!-- >>> > >>> > POST /amxbpm/WorkListService HTTP/1.1 >>> > >>> > Accept-Encoding: gzip,deflate >>> > >>> > Content-Type: text/xml;charset=UTF-8 >>> > >>> > SOAPAction: "getWorkListItems" >>> > >>> > Content-Length: 1110 >>> > >>> > Host: xivertbid05.ermont.infra.sncf.fr:8888 >>> > >>> > Connection: Keep-Alive >>> > >>> > User-Agent: Apache-HttpClient/4.1.1 (java 1.5) >>> > >>> > --> >>> > >>> > >>> > >>> > <soapenv:Envelope xmlns:api=*"http://api.brm.n2.tibco.com"* >>> > >>> > xmlns:soapenv=*"http://schemas.xmlsoap.org/soap/envelope/"*> >>> > >>> > <soapenv:Header> >>> > >>> > <wsse:Security >>> > >>> > xmlns:wsse=*" >>> > >>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd >>> > "* >>> > >>> > xmlns:wsu=*" >>> > >>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd >>> > "*> >>> > >>> > <wsse:UsernameToken wsu:Id=*"UsernameToken-9"*> >>> > >>> > <wsse:Username>tibco-admin</wsse:Username> >>> > >>> > <wsse:Password >>> > >>> > Type=*" >>> > >>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText >>> > "*>secret</wsse:Password> >>> > >>> > <wsse:Nonce >>> > >>> > EncodingType=*" >>> > >>> http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary >>> > "*>wATZQZmZIUEMuYWA8YrN1g==</wsse:Nonce> >>> > >>> > <wsu:Created>2013-06-14T08:36:06.565Z</ >>> > wsu:Created> >>> > >>> > </wsse:UsernameToken> >>> > >>> > </wsse:Security> >>> > >>> > </soapenv:Header> >>> > >>> > <soapenv:Body> >>> > >>> > <api:getWorkListItems getTotalCount=*"true"* >>> > >>> > numberOfItems=*"10"* startPosition=*"0"*> >>> > >>> > <entityID entity-type=*"RESOURCE"* >>> guid=*"tibco-admin"* >>> > >>> > model-version=*"-1"*> >>> > >>> > >>> > >>> > </entityID> >>> > >>> > >>> > >>> > </api:getWorkListItems> >>> > >>> > </soapenv:Body> >>> > >>> > </soapenv:Envelope> >>> > >>> > Java Code : >>> > >>> > package com.test.webService; >>> > >>> > >>> > import java.util.List; >>> > >>> > import com.tibco.n2.brm.api.GetWorkListItems; >>> > import com.tibco.n2.brm.api.GetWorkListItemsResponse; >>> > import com.tibco.n2.brm.api.OrderFilterCriteria; >>> > import com.tibco.n2.brm.api.WorkItem; >>> > import com.tibco.n2.brm.services.WorkListService; >>> > import com.tibco.n2.common.organisation.api.OrganisationalEntityType; >>> > import com.tibco.n2.common.organisation.api.XmlModelEntityId; >>> > import java.io.IOException; >>> > import java.util.HashMap; >>> > import java.util.Map; >>> > >>> > import javax.security.auth.callback.Callback; >>> > import javax.security.auth.callback.CallbackHandler; >>> > import javax.security.auth.callback.UnsupportedCallbackException; >>> > import javax.xml.namespace.QName; >>> > >>> > import org.apache.cxf.endpoint.Client; >>> > import org.apache.cxf.frontend.ClientProxy; >>> > import org.apache.cxf.frontend.ClientProxyFactoryBean; >>> > import org.apache.cxf.transport.http.HTTPConduit; >>> > import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; >>> > import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor; >>> > import org.apache.ws.security.WSConstants; >>> > import org.apache.ws.security.WSPasswordCallback; >>> > import org.apache.ws.security.handler.WSHandlerConstants; >>> > import org.springframework.beans.factory.InitializingBean; >>> > >>> > >>> > public class ArticWorkListService implements InitializingBean >>> > { >>> > private WorkListService workListService = null; >>> > >>> > public ArticWorkListService() >>> > { >>> > >>> > this.workListService = ArticWorkListService.create(); >>> > } >>> > >>> > public static WorkListService create() >>> > { >>> > >>> > String endpoint = " >>> http://localhost:8888/amxbpm/WorkListService >>> > "; >>> > int timeout = 60; >>> > String username = "tibco-admin"; >>> > final String password = "secret"; >>> > >>> > >>> > ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); >>> > factory.setServiceClass(WorkListService.class); >>> > factory.setAddress(endpoint); >>> > factory.setServiceName(new QName("http://api.brm.n2.tibco.com >>> > ","WorkListService_EP")); >>> > WorkListService workListService = (WorkListService) >>> > factory.create(); >>> > >>> > Client client = ClientProxy.getClient(workListService); >>> > >>> > Map<String,Object> properties = new HashMap<String, Object>(); >>> > properties.put(WSHandlerConstants.ACTION, >>> > WSHandlerConstants.USERNAME_TOKEN); >>> > properties.put(WSHandlerConstants.USER,username); >>> > properties.put(WSHandlerConstants.PASSWORD_TYPE, >>> > WSConstants.PW_TEXT );//"PasswordDigest" >>> > properties.put(WSHandlerConstants.PW_CALLBACK_REF,new >>> > CallbackHandler() >>> > { >>> > public void handle(Callback[] callbacks) throws >>> > IOException,UnsupportedCallbackException >>> > { >>> > WSPasswordCallback pc = (WSPasswordCallback) >>> callbacks[0]; >>> > pc.setPassword(password); >>> > } >>> > }); >>> > >>> > client.getOutInterceptors().add(new >>> > WSS4JOutInterceptor(properties)); >>> > >>> > HTTPConduit conduit = (HTTPConduit) client.getConduit(); >>> > >>> > long timeoutMillis = timeout * 1000; >>> > >>> > HTTPClientPolicy policy = new HTTPClientPolicy(); >>> > policy.setConnectionTimeout(timeoutMillis); >>> > policy.setReceiveTimeout(timeoutMillis); >>> > >>> > conduit.setClient(policy); >>> > >>> > return workListService; >>> > } >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > public String[] getWorklistItemsIds() >>> > { >>> > String[] ids = null; >>> > >>> > XmlModelEntityId entityId = new XmlModelEntityId(); >>> > entityId.setGuid("tibco-admin"); >>> > entityId.setEntityType(OrganisationalEntityType.RESOURCE); >>> > entityId.setModelVersion(-1); >>> > >>> > >>> > >>> > GetWorkListItems getWorkListItems = new GetWorkListItems( ); >>> > >>> > getWorkListItems.setGetTotalCount(true); >>> > getWorkListItems.setEntityID(entityId); >>> > getWorkListItems.setStartPosition(0); >>> > getWorkListItems.setNumberOfItems(10l); >>> > getWorkListItems.setOrderFilterCriteria(new >>> OrderFilterCriteria()); >>> > >>> > >>> > >>> > GetWorkListItemsResponse getWorkListItemsResponse = null; >>> > >>> > try >>> > { >>> > getWorkListItemsResponse = >>> > this.workListService.getWorkListItems(getWorkListItems); >>> > } >>> > catch(Exception e) >>> > { >>> > e.printStackTrace(); >>> > } >>> > >>> > if(getWorkListItemsResponse == null) >>> > { >>> > return new String[]{"null results"}; >>> > } >>> > >>> > List<WorkItem> workitems = >>> getWorkListItemsResponse.getWorkItems(); >>> > >>> > ids = new String[workitems.size()]; >>> > int i = 0; >>> > for (WorkItem workItem : workitems) >>> > { >>> > ids[i++] = >>> > workItem.getHeader().getItemContext().getActivityID()+"-" + >>> > >>> > workItem.getHeader().getItemContext().getActivityName()+"-" + >>> > >>> > workItem.getHeader().getItemContext().getAppID()+"-" + >>> > >>> > workItem.getHeader().getItemContext().getAppInstance()+"-" + >>> > >>> > workItem.getHeader().getItemContext().getAppInstanceDescription()+"-" + >>> > >>> > workItem.getHeader().getItemContext().getAppName()+"-" + >>> > workItem.getId().getId(); >>> > } >>> > return ids; >>> > } >>> > >>> > @Override >>> > public void afterPropertiesSet() throws Exception >>> > { >>> > try >>> > { >>> > String [] ids = this.getWorklistItemsIds(); >>> > >>> > for (String string : ids) { >>> > System.err.println(string); >>> > } >>> > >>> > } >>> > catch(Exception e) >>> > { >>> > e.printStackTrace(); >>> > } >>> > >>> > } >>> > >>> > } >>> >>> -- >>> Daniel Kulp >>> [email protected] - http://dankulp.com/blog >>> Talend Community Coder - http://coders.talend.com >>> >>> >> >
