wsdl location change from 2.0.4 to 2.0.5
I tried switching from 2.0.4 to 2.0.5-20080311.140539-8, but I have a problem with WSDLToJava. In 2.0.4 it generated *Service.java class with a relative path like wsdl/Tx.wsdl but in 2.0.5 it generates it with an absolute path like file:/C:/projects/trunk/bc/ws/template/wsdl/Tx.wsdl I tried adding the -wsdlLocation flag, and it fixed the problem in the @WebServiceClient annotation but not in the URL defined in the static block of the service class, which looks like this static { URL url = null; try { url = new URL(file:/C:/projects/trunk/bc/ws/template/wsdl/Tx.wsdl); } catch (MalformedURLException e) { System.err.println(Can not initialize the default wsdl from file:/C:/projects/trunk/bc/ws/template/wsdl/Tx.wsdl); // e.printStackTrace(); } WSDL_LOCATION = url; } So is this a bug in wsdl2java in 2.0.5? If not is there a way around it? I also get this when I startup JBoss 4.2.2 with 2.0.5. Do I need to worry about this? What does this mean? ... 2008-03-13 13:58:10,260 ERROR [STDERR] - Mar 13, 2008 1:58:10 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL INFO: Creating Service {http://www.foobar.com/Tx}TxService from WSDL: wsdl/Tx.wsdl 2008-03-13 13:58:10,432 ERROR [STDERR] - Mar 13, 2008 1:58:10 PM org.apache.cxf.endpoint.ServerImpl initDestination INFO: Setting the server's publish address to be /Tx 2008-03-13 13:58:10,432 ERROR [STDERR] - Mar 13, 2008 1:58:10 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL INFO: Creating Service {http://www.foobar.com/WorkOrder}WorkOrderService from WSDL: wsdl/WorkOrder.wsdl 2008-03-13 13:58:10,682 ERROR [STDERR] - Mar 13, 2008 1:58:10 PM org.apache.cxf.endpoint.ServerImpl initDestination INFO: Setting the server's publish address to be /WorkOrder ... Thanks, Dan
RE: trying to use ClientProxyFactoryBean but failing
Ah, I should have though of that. It's very informative. The HTML I am getting back basically says it is a 401 error with the message This request requires HTTP authentication. It appears the auth info in not getting transmitted. I added logging interceptors for both IN and OUT. On the outbound I see Headers: {SOAPAction=[], Accept=[*]} If I use the other technique (where I call new TxService().getTxPort() and add the auth to the getRequestContext() map) I see Headers: {Authorization=[Basic .=], SOAPAction=[], Accept=[*]} So I tried this and it seemed to work for authorization: ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(TxPortType.class); factory.setAddress(http://localhost/ws/services/Tx;); TxPortType port = (TxPortType)factory.create(); Client client = factory.getClientFactoryBean().getClient(); HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); AuthorizationPolicy authorization = new AuthorizationPolicy(); authorization.setUserName(...); authorization.setPassword(...); httpConduit.setAuthorization(authorization); ... port.getObjects(new ArrayListSearchTerm(0), 0, 0); *BUT* now my next problem. I am getting org.apache.cxf.binding.soap.SoapFault: Message part {http://jaxws.impl.ws.core.bricsnet.com/}getObjects was not recognized. That namespace is clearly wrong, it should be using {http://www.bricsnet.com/Tx}. I can see the wrong namespace in the outbound soap message. But how do I fix that? Thanks, Dan On Monday 10 March 2008, Daniel Kulp wrote: You're getting HTML back for some reason instead of a soap message. My only suggestion would be to do: client.getInInterceptor().add(new org.apache.cxf.interceptor.LoggingInInterceptor()); and see what it prints out. The HTML might give a clue. Dan On Friday 07 March 2008, Daniel Lipofsky wrote: username/password are not wrong because I used the same username/password for each method and the first one works. I tried the change you suggested and now I get a different error. Does this give you any more info? ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(TxPortType.class); factory.setUsername(me); factory.setPassword(hello); factory.setAddress(http://localhost/ws/services/Tx;); TxPortType port = (TxPortType)factory.create(); Client client = factory.getClientFactoryBean().getClient(); HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); httpConduit.getClient().setAllowChunking(false); httpConduit.getClient().setAutoRedirect(true); port.getObjects(new ArrayListSearchTerm(0), 0, 0); org.apache.cxf.binding.soap.SoapFault: No namespace on html element. ...
RE: trying to use ClientProxyFactoryBean but failing
Yes it does. That works! Thanks, Dan Willem Jiang wrote: Hi, Do your TxPortType.class has the @WebService annotation? If so, please use the JaxWsClientFactoryBean which will take care of this annotation to create the proxy. Here is the code snippet. ClientProxyFactoryBean factory = new ClientProxyFactoryBean(new JaxWsClientFactoryBean()); ... Willem. Daniel Lipofsky wrote: Ah, I should have though of that. It's very informative. The HTML I am getting back basically says it is a 401 error with the message This request requires HTTP authentication. It appears the auth info in not getting transmitted. I added logging interceptors for both IN and OUT. On the outbound I see Headers: {SOAPAction=[], Accept=[*]} If I use the other technique (where I call new TxService().getTxPort() and add the auth to the getRequestContext() map) I see Headers: {Authorization=[Basic .=], SOAPAction=[], Accept=[*]} So I tried this and it seemed to work for authorization: ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(TxPortType.class); factory.setAddress(http://localhost/ws/services/Tx;); TxPortType port = (TxPortType)factory.create(); Client client = factory.getClientFactoryBean().getClient(); HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); AuthorizationPolicy authorization = new AuthorizationPolicy(); authorization.setUserName(...); authorization.setPassword(...); httpConduit.setAuthorization(authorization); ... port.getObjects(new ArrayListSearchTerm(0), 0, 0); *BUT* now my next problem. I am getting org.apache.cxf.binding.soap.SoapFault: Message part {http://jaxws.impl.ws.core.bricsnet.com/}getObjects was not recognized. That namespace is clearly wrong, it should be using {http://www.bricsnet.com/Tx}. I can see the wrong namespace in the outbound soap message. But how do I fix that? Thanks, Dan On Monday 10 March 2008, Daniel Kulp wrote: You're getting HTML back for some reason instead of a soap message. My only suggestion would be to do: client.getInInterceptor().add(new org.apache.cxf.interceptor.LoggingInInterceptor()); and see what it prints out. The HTML might give a clue. Dan
RE: trying to use ClientProxyFactoryBean but failing
username/password are not wrong because I used the same username/password for each method and the first one works. I tried the change you suggested and now I get a different error. Does this give you any more info? ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(TxPortType.class); factory.setUsername(me); factory.setPassword(hello); factory.setAddress(http://localhost/ws/services/Tx;); TxPortType port = (TxPortType)factory.create(); Client client = factory.getClientFactoryBean().getClient(); HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); httpConduit.getClient().setAllowChunking(false); httpConduit.getClient().setAutoRedirect(true); port.getObjects(new ArrayListSearchTerm(0), 0, 0); org.apache.cxf.binding.soap.SoapFault: No namespace on html element. at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMes sage(ReadHeadersInterceptor.java:88) at org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor.handleMes sage(ReadHeadersInterceptor.java:56) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC hain.java:208) at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:429) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResp onse(HTTPConduit.java:1955) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTP Conduit.java:1791) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:575) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingI nterceptor.handleMessage(MessageSenderInterceptor.java:62) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC hain.java:208) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at org.apache.cxf.frontend.ClientProxy.invoke(ClientProxy.java:68) at $Proxy36.getObjects(Unknown Source) at client.WSClient1.main(WSClient1.java:33) Thanks, Dan On Friday 07 March 2008, Daniel Kulp wrote: Your error is a bit strange. It looks like it could be one of: 1) The name/password might be wrong or something and the server is re-asking you to authenticate 2) The server might be sending a redirect. You might want to put a wireshark/tcpdump trace on it to see what the server is sending back. That said, you can also try turning off the streaming and turning on the auto redirects. Performance will be slightly lower (has to buffer the full message), but it can then retry the request. TxService txService = new TxService(); TxPortType txPort = txService.getTxPort(); Client client = ClientProxy.getClient(txPort); HTTPConduit httpConduit = (HTTPConduit) client.getConduit(); httpConduit.getClient().setAllowChunking(false); httpConduit.getClient().setAutoRedirect(true); ... Dan On Thursday 06 March 2008, Daniel Lipofsky wrote: Can anyone tell me why the first form works but the second doesn't? I am trying to start using the factory stuff but it is failing. What am I doing wrong? Works: TxService txService = new TxService(); TxPortType txPort = txService.getTxPort(); MapString, Object context = ((BindingProvider) txPort).getRequestContext(); context.put(BindingProvider.USERNAME_PROPERTY, me); context.put(BindingProvider.PASSWORD_PROPERTY, hello); context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, http://localhost/ws/services/Tx;); txPort.getObjects(searchTerms, 0, 0); Fails: ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(TxPortType.class); factory.setUsername(me); factory.setPassword(hello); factory.setAddress(http://localhost/ws/services/Tx;); TxPortType client = (TxPortType)factory.create(); client.getObjects(searchTerms, 0, 0); Error: org.apache.cxf.interceptor.Fault: Could not send Message. at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndin gI nterceptor.handleMessage(MessageSenderInterceptor.java:64) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseIntercepto rC hain.java:208) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at org.apache.cxf.frontend.ClientProxy.invoke(ClientProxy.java:68) at $Proxy36.getObjects(Unknown Source) at client.WSClient1.download(WSClient1.java:41) at client.WSClient1.main(WSClient1.java:29) Caused by: java.net.HttpRetryException: cannot retry due to server authentication, in streaming
RE: WSDL2Java does not generate the setter method of a List of objects
Same for me. There is also a comment in the generated file that makes it clear this is deliberate, although I don't know why this decisison was made. You can always do foo.getAddresses().clear() foo.getAddresses().addAll(someOtherList); - Dan -Original Message- From: Landslide [mailto:[EMAIL PROTECTED] Sent: Thursday, March 06, 2008 5:49 AM To: cxf-user@incubator.apache.org Subject: WSDL2Java does not generate the setter method of a List of objects If I have a class of Contact which has an instance variable of ListAddress addresses = new ArrayListAddress(); on my server side implementation, using the tool of WSDL2Java generates the getter method: public ListAddress getAddresses() { if (addresses == null) { addresses = new ArrayListAddress(); } return this.addresses; } but it does not generate the setter method: public void setAddresses(ListAddress addresses) { this.addresses = addresses; } I am using CXF 2.0.4. -- View this message in context: http://www.nabble.com/WSDL2Java-does-not-generate-the-setter-m ethod-of-a-List-of-objects-tp15872563p15872563.html Sent from the cxf-user mailing list archive at Nabble.com.
trying to use ClientProxyFactoryBean but failing
Can anyone tell me why the first form works but the second doesn't? I am trying to start using the factory stuff but it is failing. What am I doing wrong? Works: TxService txService = new TxService(); TxPortType txPort = txService.getTxPort(); MapString, Object context = ((BindingProvider) txPort).getRequestContext(); context.put(BindingProvider.USERNAME_PROPERTY, me); context.put(BindingProvider.PASSWORD_PROPERTY, hello); context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, http://localhost/ws/services/Tx;); txPort.getObjects(searchTerms, 0, 0); Fails: ClientProxyFactoryBean factory = new ClientProxyFactoryBean(); factory.setServiceClass(TxPortType.class); factory.setUsername(me); factory.setPassword(hello); factory.setAddress(http://localhost/ws/services/Tx;); TxPortType client = (TxPortType)factory.create(); client.getObjects(searchTerms, 0, 0); Error: org.apache.cxf.interceptor.Fault: Could not send Message. at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingI nterceptor.handleMessage(MessageSenderInterceptor.java:64) at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC hain.java:208) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:276) at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:222) at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at org.apache.cxf.frontend.ClientProxy.invoke(ClientProxy.java:68) at $Proxy36.getObjects(Unknown Source) at client.WSClient1.download(WSClient1.java:41) at client.WSClient1.main(WSClient1.java:29) Caused by: java.net.HttpRetryException: cannot retry due to server authentication, in streaming mode at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnec tion.java:1012) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:367) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResp onse(HTTPConduit.java:1863) at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTP Conduit.java:1791) at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:575) at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingI nterceptor.handleMessage(MessageSenderInterceptor.java:62) ... 8 more Thanks, Dan
RE: Accessing WebService that requires username/password
I am using something like this: FoobarService foobarService = new FoobarService(); FoobarPortType foobarPort = foobarService.getFoobarPort(); context = ((BindingProvider) foobarPort).getRequestContext(); context.put(USERNAME, me); context.put(PASSWORD, hello); context.put(ENDPOINT_ADDRESS, http://localhost/ws/services/Foobar;); FoobarService and FoobarPortType are generated by wsdl2java and I include those classes in a JAR that is available on both the client side and server side. - Dan -Original Message- From: xbranko [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 05, 2008 4:38 PM To: cxf-user@incubator.apache.org Subject: Accessing WebService that requires username/password How should a webservice that requires basic username/password for authentication be accessed? The CXF service class that is autogenerated extends the javax.xml.ws.Service class. So when the client tries to instantiate it, it fails because it gets java.io.IOException: Server returned HTTP response code: 401 for URL. Looking at the documentation, and on the web, it seems that what is needed is to add something like this: //Create a dispatch instance DispatchSOAPMessage dispatch = createDispatch(WebService1, SOAPMessage.class, Service.Mode.MESSAGE); // Use Dispatch as BindingProvider BindingProvider bp = (BindingProvider) dispatch; // Optionally Configure RequestContext to send SOAPAction HTTP Header MapString, Object rc = bp.getRequestContext(); rc.put(BindingProvider.USERNAME_PROPERTY, userName); rc.put(BindingProvider.PASSWORD_PROPERTY, password); before the service hits the url. However, given that service derives from javax.xml.ws.Service class whose constructor is protected, how do I do that, given that constructor looks like: public WebServiceX() { super(WSDL_LOCATION, SERVICE); } and in the super's constructor (javax.xml.ws.Service), the class tries to connect to the url that needs the username and password, and due to java, call to super must be the first call in the deriver class's constructor. Note that this is not an https service, but just an http service that works well when I invoke it from the browser (once I provide username and password in the dialog box provided by the browser). Any help greatly appreciated! -- View this message in context: http://www.nabble.com/Accessing-WebService-that-requires-usern ame-password-tp15863184p15863184.html Sent from the cxf-user mailing list archive at Nabble.com.
RE: request/response wrapper with wsdl2java
First try and read the section in this wiki titled How can I switch my generated web service method calls from wrapper style to non wrapper-style (or vice-versa)? http://cwiki.apache.org/confluence/display/CXF20DOC/WSDL+to+Java and the related section referenced in the JAX-WS 2.1 specification. That being said I didn't have too much luck with the enableWrapperStyle flag. Instead I am controlling it with the naming convention - which is case sensitive. So if I name the operation GetObjects vesus getObjects it changes style from wrapped to unwrapped (either way the generated java method is called getObjects). - Dan -Original Message- From: Michael Nelson [mailto:[EMAIL PROTECTED] Sent: Saturday, March 01, 2008 6:21 AM To: cxf-user@incubator.apache.org Subject: request/response wrapper with wsdl2java For non-trivial methods, WSDL2Java forces me to deal with request/response wrapper classes in the client code it generates (see the 1st method as compared to the 2nd method). Is there a way to prevent this? Thanks, -mike Examples: @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE) @WebResult(name = getCustomerResponse, targetNamespace = http://customer.acme.com;, partName = parameters) @WebMethod public com.acme.customer.GetCustomerResponse getCustomer( @WebParam(partName = parameters, name = getCustomer, targetNamespace = http://customer.acme.com;) GetCustomer parameters ) throws CustomerNotFoundFault; @RequestWrapper(localName = deleteCustomer2, targetNamespace = http://customer.acme.com;, className = com.acme.customer.DeleteCustomer2) @ResponseWrapper(localName = deleteCustomer2Response, targetNamespace = http://customer.acme.com;, className = com.acme.customer.DeleteCustomer2Response) @WebMethod public void deleteCustomer2( @WebParam(name = id, targetNamespace = http://customer.acme.com;) long id );
RE: passing a flag from impl method to interceptor
So I added a header on the server side using the code below, I can see the header in client side logging, but how do I grab it on the client side? I tried an interceptor but it is not finding any headers. What am I doing wrong? Server side code: Document d = DOMUtils.createDocument(); Element overflowElem = d.createElement(overflow); overflowElem.setTextContent(String.valueOf(overflow)); QName q = new QName(SCHEMA_PREFIX + headers_ns.xsd, OverflowHeader, h); SoapHeader overflowHeader = new SoapHeader(q, overflowElem); ... ListHeader headers = CastUtils.cast((List?) messageContext.get(Header.HEADER_LIST)); ... headers.add(overflowHeader); Client side logging shows: soap:Envelope xmlns:soap=http://schemas.xmlsoap.org/soap/envelope/; soap:Headeroverflowfalse/overflow/soap:Header ... Client side code: class HeaderInterceptor extends AbstractSoapInterceptor { public HeaderInterceptor() { super(Phase.READ); } public void handleMessage(SoapMessage message) throws Fault { ListHeader headers = message.getHeaders(); if(headers.size() == 0) { log.info(HEADER.size = 0); return; } for (int i = 0; i headers.size(); i++) { log.info(HEADER + i + : + headers.get(i).getName()); } } } Thanks, Dan -Original Message- From: Daniel Lipofsky [mailto:[EMAIL PROTECTED] Sent: Friday, February 29, 2008 1:23 PM To: cxf-user@incubator.apache.org Subject: RE: passing a flag from impl method to interceptor Those all sound good, but unfortunately I am pretty much a web-services newbie, I don't have a clue how to implement that, especially the @WebParam sugestion. Do I need some entries in the WSDL, etc? the old implementation was basically outputing this: soap:Envelope ... xmlns:h=http://www.foobar.com/connector-1.5/headers_ns.xsd; soap:Header h:overflow soap:mustUnderstand=0false/h:overflow /soap:Header ... or ... h:overflow soap:mustUnderstand=0true/h:overflow ... so there are a few involved: a namespace, a node, and an attribute. I don't have to keep it the same, so maybe I can make it a lot simplier, I just need to basically communicate overflow=[true|false] somehow. Thanks, Dan On Friday 29 February 2008, Daniel Kulp wrote: Of course, I typed all that and forgot the most obvious way: Just add a parameter to your method like: @WebParam(header = true, mode = Mode.OUT) HolderString header Dan On Friday 29 February 2008, Daniel Kulp wrote: OK. This is turning into another FAQ type thing that possibly needs a sample There are a couple options open to you: First, you need the context injected in: @Resource WebServiceContext context; 1) Standard JAX-WS API's: throw the value in the WebServiceContext and in a SoapHandler, use it to modify the SAAJ object model. This is pure JAXWS and would work on any JAX-WS implementation. The problem is that with the SAAJ model, it breaks streaming and performance suffers. 2) context + CXF interceptor: again, from your impl, throw a value in the WebServiceContext and then grab that from the message in your interceptor. You can then call the soapMessage.getHeaders() thing to get the list of headers and add a Header object to it. 3) Context only: no interceptors needed. In you impl do: context. ... build a org.apache.cxf.headers.Header object ... ListHeader hdrList = (ListHeader)ctx.get(Header.HEADER_LIST)); hdrList.add(hdr); And example of this would be our system test that test this: http://svn.apache.org/repos/asf/incubator/cxf/trunk/systests/src/test/ java/org/apache/cxf/systest/outofband/header/ 3 is definitely the simplest. No interceptors needed. Nothing really to configure, etc Dan On Friday 29 February 2008, Daniel Lipofsky wrote: I have a csae where I want to set something in the SOAP response header based on what happened in the execution of the method implementation. I suppose I want to extend AbstractSoapInterceptor, but what I can't figure out is how to pass a flag from the method to the interceptor. I thought about sticking it in the ServletRequest attribute map but I don't see a way to access that from the interceptor. Any way to do it would be fine. also is there an example of adding an element to a SOAP header? Thanks, Dan
RE: WSDLtoJava
I'm not sure why it is using that package, it usually bases the package name off the namespace URL, but you can override by adding the -p parameter like this arg value=-p/ arg value=com.mycompany.foobar.ws.impl.jaxws/ try that and see if it helps. - Dan -Original Message- From: John-M Baker [mailto:[EMAIL PROTECTED] Sent: Friday, February 29, 2008 9:20 AM To: [EMAIL PROTECTED] Subject: WSDLtoJava Hello, I'm looking for a reliable wsdl2java product and I'm looking at CXF. I've generated a set of sources from a WSDL but a set of java.util.xsd.* sources have been generated. When compiled and run, the VM complains that java.util is a protected package (because it is). I'm generating the source using the following ant configuration: java classname=org.apache.cxf.tools.wsdlto.WSDLToJava fork=true arg value=-client/ arg value=-d/ arg value=${dist.dir}/stubs/ arg value=${dist.dir}/Query.wsdl/ classpath path refid=classpath.cxf/ /classpath /java Can someone give me some guidance on what I may be doing wrong? Thanks, John --- This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and delete this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional EU corporate and regulatory disclosures.
passing a flag from impl method to interceptor
I have a csae where I want to set something in the SOAP response header based on what happened in the execution of the method implementation. I suppose I want to extend AbstractSoapInterceptor, but what I can't figure out is how to pass a flag from the method to the interceptor. I thought about sticking it in the ServletRequest attribute map but I don't see a way to access that from the interceptor. Any way to do it would be fine. also is there an example of adding an element to a SOAP header? Thanks, Dan
RE: WebServiceContext violates loader constraints
On Friday February 29, 2008 Daniel Kulp wrote: On Thursday 28 February 2008, Daniel Lipofsky wrote: Well, I still can't figure out what changed. But JBoss does include that class in jboss-jaxws.jar. Removing the CXF version (jaxws-api-2.0.jar) from my install solved the problem. Is there a list of JARs to avoid for a JBoss install? I would suspect most of the API-type JARs would be duplicated in JBoss. We have a page for App server integration issues at: http://cwiki.apache.org/CXF20DOC/appserverguide.html For JBoss, I think it says to muck with classloader config wrather than deleting jars. Either way probably works though. Ah, I read that a few weeks ago. I haven't tried that yet with CXF. I tried it last month when I was trying to get Glue to work with JBoss (it doesn't) and I had really bad results, it did stop rejecting the Glue supplied classes but all the other components broke. Maybe I just don't know how to do it properly, but I will stick with trying to delete conflicting JARs for now. Thanks, Dan
error trying to add logging in cxf-servlet.xml
So I want to add some custom logging, but first I just tried the logging example in the wiki page for configuration. I get an exception on startup. What am I doing wrong? The only difference I see is between my cxf-servlet.xml and the example is that the example has no jaxws:endpoint entires. CXF 2.0.4, JBoss 4.2.2, JDK 1.5.0 My cxf-servlet.xml: ?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:cxf=http://cxf.apache.org/core; xmlns:jaxws=http://cxf.apache.org/jaxws; xsi:schemaLocation= http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd; bean id=logInbound class=org.apache.cxf.interceptor.LoggingInInterceptor/ bean id=logOutbound class=org.apache.cxf.interceptor.LoggingOutInterceptor/ cxf:bus cxf:inInterceptors ref bean=logInbound/ /cxf:inInterceptors cxf:outInterceptors ref bean=logOutbound/ /cxf:outInterceptors cxf:inFaultInterceptors ref bean=logOutbound/ /cxf:inFaultInterceptors /cxf:bus jaxws:endpoint id=tx implementor=com.foobar.txmanager.ws.TxImpl wsdlLocation=WEB-INF/wsdl/Tx.wsdl address=/tx /jaxws:endpoint jaxws:endpoint id=person implementor=com.foobar.core.ws.PersonImpl wsdlLocation=WEB-INF/wsdl/Person.wsdl address=/person /jaxws:endpoint /beans I tried the plain Spring bean elements example too and got the same error. The error: INFO: Build endpoints from config-location: /WEB-INF/cxf-servlet.xml 2008-02-29 12:02:53,393 INFO [XmlBeanDefinitionReader] - Loading XML bean definitions from /WEB-INF/cxf-servlet.xml 2008-02-29 12:02:53,503 INFO [GenericApplicationContext] - Refreshing [EMAIL PROTECTED]: display name [EMAIL PROTECTED]; startup date [Fri Feb 29 12:02:53 MST 2008]; root of context hierarchy 2008-02-29 12:02:53,503 INFO [GenericApplicationContext] - Bean factory for application context [EMAIL PROTECTED]: [EMAIL PROTECTED] 145e 2008-02-29 12:02:53,518 INFO [DefaultListableBeanFactory] - Pre-instantiating singletons in [EMAIL PROTECTED] 145e: defining beans [logInbound,logOutbound,cxf,tx,person]; root of factory hierarchy 2008-02-29 12:02:54,081 ERROR [STDERR] - Feb 29, 2008 12:02:54 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL INFO: Creating Service {http://www.bricsnet.com/Tx}TxService from WSDL: WEB-INF/wsdl/Tx.wsdl 2008-02-29 12:02:54,081 INFO [DefaultListableBeanFactory] - Destroying singletons in [EMAIL PROTECTED] 145e: defining beans [logInbound,logOutbound,cxf,tx,person]; root of factory hierarchy 2008-02-29 12:02:54,097 ERROR [[/ws]] - StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tx': Invocation of init method failed; nested exception is java.lang.NullPointerException Caused by: java.lang.NullPointerException at org.apache.cxf.wsdl11.WSDLServiceFactory.init(WSDLServiceFactory.java: 81) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildService FromWSDL(ReflectionServiceFactoryBean.java:269) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeSe rviceModel(ReflectionServiceFactoryBean.java:360) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(Refle ctionServiceFactoryBean.java:156) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsService FactoryBean.java:89) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint( AbstractWSDLBasedEndpointFactory.java:74) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java: 108) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBea n.java:147) at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:299) at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:230) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:181) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:352) ... Thanks, Dan
RE: passing a flag from impl method to interceptor
Those all sound good, but unfortunately I am pretty much a web-services newbie, I don't have a clue how to implement that, especially the @WebParam sugestion. Do I need some entries in the WSDL, etc? the old implementation was basically outputing this: soap:Envelope ... xmlns:h=http://www.foobar.com/connector-1.5/headers_ns.xsd; soap:Header h:overflow soap:mustUnderstand=0false/h:overflow /soap:Header ... or ... h:overflow soap:mustUnderstand=0true/h:overflow ... so there are a few involved: a namespace, a node, and an attribute. I don't have to keep it the same, so maybe I can make it a lot simplier, I just need to basically communicate overflow=[true|false] somehow. Thanks, Dan On Friday 29 February 2008, Daniel Kulp wrote: Of course, I typed all that and forgot the most obvious way: Just add a parameter to your method like: @WebParam(header = true, mode = Mode.OUT) HolderString header Dan On Friday 29 February 2008, Daniel Kulp wrote: OK. This is turning into another FAQ type thing that possibly needs a sample There are a couple options open to you: First, you need the context injected in: @Resource WebServiceContext context; 1) Standard JAX-WS API's: throw the value in the WebServiceContext and in a SoapHandler, use it to modify the SAAJ object model. This is pure JAXWS and would work on any JAX-WS implementation. The problem is that with the SAAJ model, it breaks streaming and performance suffers. 2) context + CXF interceptor: again, from your impl, throw a value in the WebServiceContext and then grab that from the message in your interceptor. You can then call the soapMessage.getHeaders() thing to get the list of headers and add a Header object to it. 3) Context only: no interceptors needed. In you impl do: context. ... build a org.apache.cxf.headers.Header object ... ListHeader hdrList = (ListHeader)ctx.get(Header.HEADER_LIST)); hdrList.add(hdr); And example of this would be our system test that test this: http://svn.apache.org/repos/asf/incubator/cxf/trunk/systests/src/test/ java/org/apache/cxf/systest/outofband/header/ 3 is definitely the simplest. No interceptors needed. Nothing really to configure, etc Dan On Friday 29 February 2008, Daniel Lipofsky wrote: I have a csae where I want to set something in the SOAP response header based on what happened in the execution of the method implementation. I suppose I want to extend AbstractSoapInterceptor, but what I can't figure out is how to pass a flag from the method to the interceptor. I thought about sticking it in the ServletRequest attribute map but I don't see a way to access that from the interceptor. Any way to do it would be fine. also is there an example of adding an element to a SOAP header? Thanks, Dan
WebServiceContext violates loader constraints
Suddenly I am getting this error: 2008-02-28 13:47:02,631 ERROR [STDERR] - Feb 28, 2008 1:47:02 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Application has thrown exception, unwinding now: Class javax/xml/ws/WebServiceContext violates loader constraints It was working fine yesterday, I don't know why it would have changed (I am changing lots of things but nothing that seems relevant) I know this often has to do with the same class in multiple JARs. But I removed the JARs that came with CXF from the EAR level, they are now only in the WAR, and that didn't solve it. Any ideas? I am on JBoss 4.2.2, JDK 1.5.0, CXF 2.0.4. Thanks, Dan
RE: WebServiceContext violates loader constraints
Well, I still can't figure out what changed. But JBoss does include that class in jboss-jaxws.jar. Removing the CXF version (jaxws-api-2.0.jar) from my install solved the problem. Is there a list of JARs to avoid for a JBoss install? I would suspect most of the API-type JARs would be duplicated in JBoss. Thanks, Dan -Original Message- From: Daniel Kulp [mailto:[EMAIL PROTECTED] Sent: Thursday, February 28, 2008 2:03 PM To: cxf-user@incubator.apache.org Cc: Daniel Lipofsky Subject: Re: WebServiceContext violates loader constraints Looks like there are two different jaxws-api jars being picked up somehow.That's definitely what I'd check for. Not sure why it would start happening today unles you are on a 2.1 snapshot using maven or something. I did a deploy with some updated WebServiceContext injection code this morning. That definitely wouldn't affect 2.0.4 though. Dan On Thursday 28 February 2008, Daniel Lipofsky wrote: Suddenly I am getting this error: 2008-02-28 13:47:02,631 ERROR [STDERR] - Feb 28, 2008 1:47:02 PM org.apache.cxf.phase.PhaseInterceptorChain doIntercept INFO: Application has thrown exception, unwinding now: Class javax/xml/ws/WebServiceContext violates loader constraints It was working fine yesterday, I don't know why it would have changed (I am changing lots of things but nothing that seems relevant) I know this often has to do with the same class in multiple JARs. But I removed the JARs that came with CXF from the EAR level, they are now only in the WAR, and that didn't solve it. Any ideas? I am on JBoss 4.2.2, JDK 1.5.0, CXF 2.0.4. Thanks, Dan -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
java2wsdl yeilds WSDL file that causes NullPointerException
I was using WSDLToJava but now I am trying to use JavaToWSDL. I have a bunch of web-services with the same signature and they all inherit from a common abstract impl class, so it seems best to generate the WSDL. I am trying to deploy on JBoss 4.2.2 / JDK 1.5.0 / CXF 2.0.4 Using the generated WSDL in the WAR file gives the following exception. Switching back to the handwritten WSDL makes it work fine. there are 2 things that might be contributing factors * I am using a mix of wrapper-style and non-wrapper style * My concrete impl classes inherit from an abstract impl class which contain most of the methods. The generated WSDL seems to contain a schema section for both with much repeating. Any ideas how to get this to work? 2008-02-26 15:16:58,400 ERROR [[/ws2]] - Servlet /ws2 threw load() exception java.lang.NullPointerException at org.apache.cxf.jaxws.support.JaxWsServiceConfiguration.getInParameterNam e(JaxWsServiceConfiguration.java:195) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.getInParamet erName(ReflectionServiceFactoryBean.java:1678) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.getInPartNam e(ReflectionServiceFactoryBean.java:1658) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializePa rameter(ReflectionServiceFactoryBean.java:586) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeCl assInfo(ReflectionServiceFactoryBean.java:563) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeWSDLOpera tion(JaxWsServiceFactoryBean.java:165) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeWS DLOperations(ReflectionServiceFactoryBean.java:476) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.initializeWSDLOpera tions(JaxWsServiceFactoryBean.java:174) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildService FromWSDL(ReflectionServiceFactoryBean.java:274) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeSe rviceModel(ReflectionServiceFactoryBean.java:360) at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(Refle ctionServiceFactoryBean.java:156) at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsService FactoryBean.java:89) at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint( AbstractWSDLBasedEndpointFactory.java:74) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java: 108) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBea n.java:147) at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:299) at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:230) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:181) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:352) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1240 ) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1205) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac tory.createBean(AbstractAutowireCapableBeanFactory.java:425) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObjec t(AbstractBeanFactory.java:251) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.g etSingleton(DefaultSingletonBeanRegistry.java:156) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab stractBeanFactory.java:248) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab stractBeanFactory.java:160) at org.springframework.beans.factory.support.DefaultListableBeanFactory.pre InstantiateSingletons(DefaultListableBeanFactory.java:287) at org.springframework.context.support.AbstractApplicationContext.refresh(A bstractApplicationContext.java:352) at org.apache.cxf.transport.servlet.CXFServlet.loadAdditionalConfig(CXFServ let.java:145) at org.apache.cxf.transport.servlet.CXFServlet.loadSpringBus(CXFServlet.jav a:113) at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:63) at
RE: java2wsdl yeilds WSDL file that causes NullPointerException
OK, I solved this original problem but I have more questions: How do you control the soap location. Right now it is outputing soap:address location=http://localhost:9090/hello/ which is not correct. Also, can I override this programmatically in the client? Thanks, Dan p.s. I solved it by removing package-info.java and also BasePortType.java and BaseService.java which were hanging around from when I generated things for the abstract class; I also removed a reference to targetNamespace=.../Base.wsdl that was hanging around in WSException.java. Not sure what really did it.
best practices for Map and List in webservices
I have got some WebServices that basically take and return MapString,String and ListString. I am wondering what is considered the best way to do this, especially for interoperability with both Java and .NET. I don't have to use the Java collections (although it sure is convenient). Previously we used WebMethods Glue which provided this for us, but I understand it was not great for interoperability. Thanks, Dan
Loading data into pre-existing objects
I am trying to convert our webservices from WebMethods Glue to CXF and I am looking for some advice and good examples. The main thing we do is upload and download a list of objects, persisted to the database via Hibernate or EJBs. Our SOAP XML files look something like this DataList ... Building alphaIdTest1/alphaId address123 Main St/address cityNo Where/city stateProvinceCA/stateProvince someNestedObject fieldvalue/field /someNestedObject /Building Building alphaIdTest2/alphaId address456 Main St/address /Building /DataList and then we have a BuildingDTO which holds the data with a BuildingServiceEJB and BuildingEJB (and similar for about 40 other objects, all which can be in DataList). I would like to use the existing data objects to get the data rather than creating new ones with WSDLToJava. Any suggestions on how to best to this? Thanks, Dan
RE: client code to access java_first_jaxws on tomcat
Thanks for the speedy replies. Willem's simple change got my client working, and Glen's well documented and more complex examples will probably save my sanity as I progress in this project. - Dan -Original Message- From: Daniel Lipofsky [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 19, 2008 5:24 PM To: cxf-user@incubator.apache.org Subject: client code to access java_first_jaxws on tomcat I am trying to learn CXF, I have installed the java_first_jaxws sample on Tomcat 5.5 and can see the wsdl at http://localhost:8080/helloworld/services/hello_world?wsdl But what I don't understand is how I can run webservices against that server. Does anyone have client code that will allow me to test? I tried modifying Client.java like this: private static final QName SERVICE_NAME = new QName(http://server.hw.demo/;, HelloWorld); private static final QName PORT_NAME = new QName(http://server.hw.demo/;, HelloWorldPort); public static void main(String args[]) throws Exception { Service service = Service.create(SERVICE_NAME); String endpointAddress = http://localhost:8080/helloworld/services/hello_world?wsdl;; service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); HelloWorld hw = service.getPort(HelloWorld.class); System.out.println(hw.sayHi(World)); } but all I got was org.apache.cxf.binding.soap.SoapFault: http://schemas.xmlsoap.org/wsdl/;, the namespace on the definitions element, is not a valid SOAP version. I tried a bunch of variations too with no success. How does one make this work? (I'd also appreciate an example for wsdl_first_soap12 or any of the others) Thanks, Dan
client code to access java_first_jaxws on tomcat
I am trying to learn CXF, I have installed the java_first_jaxws sample on Tomcat 5.5 and can see the wsdl at http://localhost:8080/helloworld/services/hello_world?wsdl But what I don't understand is how I can run webservices against that server. Does anyone have client code that will allow me to test? I tried modifying Client.java like this: private static final QName SERVICE_NAME = new QName(http://server.hw.demo/;, HelloWorld); private static final QName PORT_NAME = new QName(http://server.hw.demo/;, HelloWorldPort); public static void main(String args[]) throws Exception { Service service = Service.create(SERVICE_NAME); String endpointAddress = http://localhost:8080/helloworld/services/hello_world?wsdl;; service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, endpointAddress); HelloWorld hw = service.getPort(HelloWorld.class); System.out.println(hw.sayHi(World)); } but all I got was org.apache.cxf.binding.soap.SoapFault: http://schemas.xmlsoap.org/wsdl/;, the namespace on the definitions element, is not a valid SOAP version. I tried a bunch of variations too with no success. How does one make this work? (I'd also appreciate an example for wsdl_first_soap12 or any of the others) Thanks, Dan