Re: How best to transform a XML file into a message.
Folks, I know this is a free forum thus folks are free to ignore questions. On the question below, the big question I have comes from my ignorance of the plumbing of Web Services. Any feedback, even feedback such as, Sam go learn more about the SOAP envelope to find out your own confort level, fore this is something only you can answer. would be much appreciated. Sam P.S. I am starting to talk to WSO2 about some paid support, I am hoping to get some feedback on this sooner rather then later, though ;) On Wed, Apr 1, 2009 at 7:34 AM, Sam Carleton scarle...@miltonstreet.comwrote: My first operation I need to implement with Axis2/C is sort of interesting... I have an XML file on the server that needs to be transformed and returned to the client. The question is how best to do this transformation? A: Do I use the code generated by WSDL2C and in the call to the operation populate the response using all the generated code and allowing the generated code to serialize it into the SOAP message? B: Do I write some XSLT (which I do know) to do the transformation in the services Invoke method? I like option B better, but I have a feeling there is some namespace and endpoint data that is magically done for me in option A. Myself being new to this whole thing, which would be faster for me to implement? I am thinking A, but would the learning experience of implementing B end up making my life a lot easier down the road? As I just posed, I have a lot more to learn about the whole WS-* stuff and to figure out where and/or if that will fit into my solution, would option B prevent me from using the other WS-* or do those things kick in before/after the services invoke? Sam
Re: How best to transform a XML file into a message.
Sam, IMHO, it isn't worth doing web services unless you use the autogenerated code. I learned from experience to stop hand jamming xml. If your WSDL changes, you want to re-autogenerate the plumbing code on both your client and server side ... and with any luck, any code changes you have are isolated in the code you had to write in order to use the objects generated on your client side. But, I did find your question hard to answer. I've been successful hand jamming xml (and doing xslt) and wrapping it in a SOAP env for old fashioned rpc wsdls. But with doc-literal, you should try to use the objects generated by axis. did this help? On Thu, Apr 2, 2009 at 4:44 AM, Sam Carleton scarle...@miltonstreet.comwrote: Folks, I know this is a free forum thus folks are free to ignore questions. On the question below, the big question I have comes from my ignorance of the plumbing of Web Services. Any feedback, even feedback such as, Sam go learn more about the SOAP envelope to find out your own confort level, fore this is something only you can answer. would be much appreciated. Sam P.S. I am starting to talk to WSO2 about some paid support, I am hoping to get some feedback on this sooner rather then later, though ;) On Wed, Apr 1, 2009 at 7:34 AM, Sam Carleton scarle...@miltonstreet.comwrote: My first operation I need to implement with Axis2/C is sort of interesting... I have an XML file on the server that needs to be transformed and returned to the client. The question is how best to do this transformation? A: Do I use the code generated by WSDL2C and in the call to the operation populate the response using all the generated code and allowing the generated code to serialize it into the SOAP message? B: Do I write some XSLT (which I do know) to do the transformation in the services Invoke method? I like option B better, but I have a feeling there is some namespace and endpoint data that is magically done for me in option A. Myself being new to this whole thing, which would be faster for me to implement? I am thinking A, but would the learning experience of implementing B end up making my life a lot easier down the road? As I just posed, I have a lot more to learn about the whole WS-* stuff and to figure out where and/or if that will fit into my solution, would option B prevent me from using the other WS-* or do those things kick in before/after the services invoke? Sam
RE: How best to transform a XML file into a message.
Date: Thu, 2 Apr 2009 08:37:01 -0700 Subject: Re: How best to transform a XML file into a message. From: To: axis-c-user@ws.apache.org Sam, IMHO, it isn't worth doing web services unless you use the autogenerated code. I learned from experience to stop hand jamming xml. If your WSDL changes, you want to re-autogenerate the plumbing code on both your client and server side ... and with any luck, any code changes you have are isolated in the code you had to write in order to use the objects generated on your client side. I spent a lot of time with the C generated code and never did get it to work well I so went back to java axis and everything pretty much worked right away. But, the reason for mentioning this now, is that I have subsequently found that our service provider often updates the WSDL file. This turns out to be fine in java since I can diff the wsdl files, re generate the class files unless there is something gross that has been changed, and then almost all of my reflection-invoked code still runs: I can archive, upload, and download things in a complete and consistent manner by just looking for public get/set methods. Is there some similar facility in the C- axis to reflection invokation? I guess if you put all that in a DLL/SO you can load the library of your choice. With java, if I really need to, I can point the class path to pick up either the current or prior WSDL class files with little effort. _ Rediscover Hotmail®: Now available on your iPhone or BlackBerry http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile1_042009
RE: How best to transform a XML file into a message.
Hi Mike. The Java route for different versions of the WSDL is a very good solution. Especially if you couple this with Maven2 and the use of an artifact repository such as Archiva (http://archiva.apache.org/). Then, you can construct an individual, versioned JAR file for each version of the WSDL. In your Java code the run the application you can then simply configure it to use the appropriate version as necessary. This would remove the need to update your classpath - you'd simply let Maven2 manage the dependencies. Another follow on question to your previous email: Are they changing the WSDL or the Schema of the web services? Alastair This e-mail and any attachments are intended solely for the use of the intended recipient(s) and may contain legally privileged, proprietary and/or confidential information. Any use, disclosure, dissemination, distribution or copying of this e-mail and any attachments for any purposes that have not been specifically authorized by the sender is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail and permanently delete all copies and attachments. The entire content of this e-mail is for information purposes only and should not be relied upon by the recipient in any way unless otherwise confirmed in writing by way of letter or facsimile. -Original Message- From: Mike Marchywka [mailto:marchy...@hotmail.com] Sent: Thursday, April 02, 2009 9:18 AM To: axis-c-user@ws.apache.org Subject: RE: How best to transform a XML file into a message. Date: Thu, 2 Apr 2009 08:37:01 -0700 Subject: Re: How best to transform a XML file into a message. From: To: axis-c-user@ws.apache.org Sam, IMHO, it isn't worth doing web services unless you use the autogenerated code. I learned from experience to stop hand jamming xml. If your WSDL changes, you want to re-autogenerate the plumbing code on both your client and server side ... and with any luck, any code changes you have are isolated in the code you had to write in order to use the objects generated on your client side. I spent a lot of time with the C generated code and never did get it to work well I so went back to java axis and everything pretty much worked right away. But, the reason for mentioning this now, is that I have subsequently found that our service provider often updates the WSDL file. This turns out to be fine in java since I can diff the wsdl files, re generate the class files unless there is something gross that has been changed, and then almost all of my reflection-invoked code still runs: I can archive, upload, and download things in a complete and consistent manner by just looking for public get/set methods. Is there some similar facility in the C- axis to reflection invokation? I guess if you put all that in a DLL/SO you can load the library of your choice. With java, if I really need to, I can point the class path to pick up either the current or prior WSDL class files with little effort. _ Rediscover Hotmail(r): Now available on your iPhone or BlackBerry http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover _Mobile1_042009
RE: How best to transform a XML file into a message.
Subject: RE: How best to transform a XML file into a message. Date: Thu, 2 Apr 2009 09:32:47 -0700 From: spam haven CT To: axis-c-user@ws.apache.org Hi Mike. The Java route for different versions of the WSDL is a very good solution. Especially if you couple this with Maven2 and the use of an artifact repository such as Archiva (http://archiva.apache.org/). Then, you can construct an individual, versioned JAR file for each version of the WSDL. In your Java code the run the application you can then simply configure it to use the appropriate version as necessary. This would remove the need to update your classpath - you'd simply let Maven2 manage the dependencies. Thanks, I'll look at that but couldn't I just use subversion for that? If I find a new wsdl file, I can just copy if over a local svn check out, commit the new one, and then go back and play around if needed. Another follow on question to your previous email: Are they changing the WSDL or the Schema of the web services? I hate to ask but does the XML file actually relate to your WSDL or is it unrelated DATA, intended for a local XML parser to examine? You may be just asking a question like, how do I send a JPEG or PDF file in a SOAP response? Alastair _ Windows Live™: Keep your life in sync. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_042009
Re: How best to transform a XML file into a message.
On Thu, Apr 2, 2009 at 11:37 AM, cara pinkgran...@gmail.com wrote: Sam, IMHO, it isn't worth doing web services unless you use the autogenerated code. I learned from experience to stop hand jamming xml. If your WSDL changes, you want to re-autogenerate the plumbing code on both your client and server side ... and with any luck, any code changes you have are isolated in the code you had to write in order to use the objects generated on your client side. Very good point, things will change and using the autogenerated code will make that far less painful. Thank you. Sam
RE: How best to transform a XML file into a message.
Mike. Thanks, I'll look at that but couldn't I just use subversion for that? If I find a new wsdl file, I can just copy if over a local svn check out, commit the new one, and then go back and play around if needed. That's true you can do that. I would only suggest going that route if you only move forward and will never need to support a previous version. For our project we get a new version of the WSDL file every few months. Thus we use the Archiva method for management of these artifacts as not all client operations of our service update to the latest immediately so we end up supporting multiple versions of a single WSDL. This in itself is it's own task especially when dealing with generated code and namespaces... I hate to ask but does the XML file actually relate to your WSDL or is it unrelated DATA, intended for a local XML parser to examine? You may be just asking a question like, how do I send a JPEG or PDF file in a SOAP response? I prefer to think of web services as a combination of operations/signatures and payloads. The XML is the payload and is defined by the XML Schema which is generally referenced from or embedded in the WSDL. The operation signature is defined by the WSDL with wsdl:operation and wsdl:message. Example: !-- Message payload -- wsdl:types xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema; xmlns:msg=http://www.mycompany.com; xs:element name=MyOperationRequestElement type=xs:string/ xs:element name=MyOperationResponseElement type=xs:string/ /xs:schema /wsdl:types !-- binding the operation input/output to the payload -- wsdl:message name=MyOperationRequest wsdl:part name=body element=msg:MyOperationRequestElement/ /wsdl:message wsdl:message name=MyOperationResponse wsdl:part name=body element=msg:MyOperationResponseElement/ /wsdl:message !-- defining the operations -- wsdl:portType name=MyPortType wsdl:operation name=MyOperation wsdl:input message=tns:MyOperationRequest/ wsdl:output message=tns:MyOperationResponse/ /wsdl:operation /wsdl:portType wsdl:binding name=MyPortBinding type=tns:MyPortType soap:binding transport=http://schemas.xmlsoap.org/soap/http; style=document/ wsdl:operation name=MyOperation soap:operation soapAction=MyOperation/ wsdl:input soap:body parts=body use=literal/ /wsdl:input wsdl:output soap:body parts=body use=literal/ /wsdl:output /wsdl:operation /wsdl:binding It's fine to have the WSDL but you need a schema definition to go along with it. It ends up looking something like this: Request message: soap:envelope soap:body msg:MyOperationRequestElementfoo/msg:MyOperationRequestElement /soap:body /soap:envelope Response message: soap:envelope soap:body msg:MyOperationResponseElementfoo/msg:MyOperationResponseElement /soap:body /soap:envelope There's a quick and dirty intro to WSDL. This is why I was asking if the XML Schema was changing or just the operation signatures... Disclaimer: I did this off the top of my head! Alastair This e-mail and any attachments are intended solely for the use of the intended recipient(s) and may contain legally privileged, proprietary and/or confidential information. Any use, disclosure, dissemination, distribution or copying of this e-mail and any attachments for any purposes that have not been specifically authorized by the sender is strictly prohibited. If you are not the intended recipient, please immediately notify the sender by reply e-mail and permanently delete all copies and attachments. The entire content of this e-mail is for information purposes only and should not be relied upon by the recipient in any way unless otherwise confirmed in writing by way of letter or facsimile. -Original Message- From: Mike Marchywka [mailto:marchy...@hotmail.com] Sent: Thursday, April 02, 2009 9:40 AM To: axis-c-user@ws.apache.org Subject: RE: How best to transform a XML file into a message. Subject: RE: How best to transform a XML file into a message. Date: Thu, 2 Apr 2009 09:32:47 -0700 From: spam haven CT To: axis-c-user@ws.apache.org Hi Mike. The Java route for different versions of the WSDL is a very good solution. Especially if you couple this with Maven2 and the use of an artifact repository such as Archiva (http://archiva.apache.org/). Then, you can construct an individual, versioned JAR file for each version of the WSDL. In your Java code the run the application you can then simply configure it to use the appropriate version as necessary. This would remove the need to update your classpath - you'd simply let Maven2 manage the dependencies. Thanks, I'll look at that but couldn't I just use subversion for that? If I find a new wsdl
Re: How best to transform a XML file into a message.
I agree with everyone that the java implementations have been ahead of the c. Also, a whole lot depends on that WSDL. Read the online IBM article about 'Which WSDL should I use?' The service side can make decisions like returning an XML response message all the time instead of throwing an exception. Exceptions tend to be a pain in rearend in different languages including C and ZSI (Python). they work just fine in java. I ended up doing document-literal WSDLs all in java (Axis and now JAX-WS), but the design was often driven by what languages were on the client-side. If we had C++ and Python clients to integrate, the WSDL had to be pretty conservative. On the service-side in java I have even DOM parsed an XML file and filled the autogenerated classes created by the WSDL and XSD. There are also tricks to changing the service-side ... for example, you can try to nail your interface methods (WSDL) down and only add to your XSD. In some cases existing clients can just keep using the service without re-autogenerating ... but this is the beauty of a cleaner code design which capitalizes on the extensibility and standard parsing of XML. I'd like to know if other companies are doing a good job of managing and versioning their WSDL and XSD files (they should be separate).? or, are they just letting the whole governance and configuration management fall apart.? he he ... I'm laughing pretty hard right now. Well, Sam, perhaps we have now bent your ear with too much information. No matter what, don't feel bad ... there is a lot to learn ... and I swear, you can only learn this junk by doing ... LOL cara On Thu, Apr 2, 2009 at 9:52 AM, Sam Carleton scarle...@gmail.com wrote: On Thu, Apr 2, 2009 at 11:37 AM, cara pinkgran...@gmail.com wrote: Sam, IMHO, it isn't worth doing web services unless you use the autogenerated code. I learned from experience to stop hand jamming xml. If your WSDL changes, you want to re-autogenerate the plumbing code on both your client and server side ... and with any luck, any code changes you have are isolated in the code you had to write in order to use the objects generated on your client side. Very good point, things will change and using the autogenerated code will make that far less painful. Thank you. Sam
Re: How best to transform a XML file into a message.
On Thu, Apr 2, 2009 at 1:16 PM, cara pinkgran...@gmail.com wrote: he he ... I'm laughing pretty hard right now. Well, Sam, perhaps we have now bent your ear with too much information. No matter what, don't feel bad ... there is a lot to learn ... and I swear, you can only learn this junk by doing ... Well, it is a lot of info, not all of which I can absorb, but I am trying;) I am just glad I finally get to dig into web services and WSDL, it is all fun stuff! Sam
Axis2 service and spring problem, can't find Spring's ApplicationContext.
Hi. I have added Axis2 and a service to a web application. I tried first with a simple echo string method in the service which I have gotten to work. But when I add ApplicationContextHolder.getContext() to the method there is an exception when the client tries to connect to the web service, and Tomcat shows the error can't find Spring's ApplicationContext. When deployed to Tomcat there was no errors. I have read about the spring axis2 integration problem and tried following the guides (for instance on the apache axis2 site). My goal is to get the context.xml so that I can send it as parameter when instantiating an application I want to use which uses spring ( new SpringAppl sa = new SpringAppl(ApplicationContextHolder.getContext()); ) and then use a couple of methods in that class and return a result to the client using the service. Anyone know what I am doing wrong? Exceptions and content of the files I am using are pasted below. -Az. The exceptions: (The first from when I used springappcontext.. in the services.xml and the second when I used the springappcontext...) Caused by: java.lang.Exception: Axis2 Can't find Spring's ApplicationContext at org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObj ectSupplier.getServiceObject(SpringAppContextAwareObjectSupplier.java:53) ... 28 more --- Caused by: org.apache.axis2.AxisFault: Axis2 Can't find Spring's ApplicationCont ext at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430) at org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObj ectSupplier.getServiceObject(SpringAppContextAwareObjectSupplier.java:63) ... 28 more Caused by: java.lang.Exception: Axis2 Can't find Spring's ApplicationContext at org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObj ectSupplier.getServiceObject(SpringAppContextAwareObjectSupplier.java:53) ... 28 more The java class: --- . package xyz; . import org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder; . import org.springframework.context.ApplicationContext; . public class MyServ { . public String serExe() { .ApplicationContext ctx = ApplicationContextHolder.getContext(); .return test; . } .} The services.xml: - serviceGroup service name=MyServ description blabla /description parameter name=ServiceObjectSupplier org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier/parameter parameter name=SpringBeanNameMyServ/parameter parameter name=ServiceClass locked=falsexyz.MyServ/parameter operation name=serExe messageReceiver class=org.apache.axis2.rpc.receivers.RPCMessageReceiver/ /operation /service /serviceGroup The web.xml: !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; web-app display-nameBlabla/display-name servlet servlet-nameAxisServlet/servlet-name display-nameApache-Axis Servlet/display-name servlet-class org.apache.axis2.transport.http.AxisServlet /servlet-class load-on-startup1/load-on-startup /servlet servlet-mapping servlet-nameAxisServlet/servlet-name url-pattern/services/*/url-pattern /servlet-mapping context-param param-namecontextConfigLocation/param-name param-value/WEB-INF/context.xml/param-value /context-param context-param param-namecontextClass/param-name param-value ( path of a specific kind of WebApplicationContext class which the SpringAppl expects...) /param-value /context-param listener listener-class org.springframework.web.context.ContextLoaderListener /listener-class /listener /web-app _ Ditt liv. Dine ting. Alt på ett sted med Windows Live™. http://windowslive.no
Re: Axis2 service and spring problem, can't find Spring's ApplicationContext.
Hi Azazel, parameter name=ServiceObjectSupplier org.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier/parameter You are loading SpringAppContext through ContextLoaderListener , so you should use SpringServletContextObjectSupplier instead of SpringAppContextAwareObjectSupplier. parameter name=ServiceObjectSupplier locked=falseorg.apache.axis2.extensions.spring.receivers.SpringServletContextObjectSupplier/parameter Thanks , -- Sagara Gunathunga Blog - http://ssagara.blogspot.com Web - http://sagaras.awardspace.com/
Re: [Axis2] Rampart/WSS4J timestamp check
Hi, I am facing the same problem as mentioned by you.I hope you have found the solution to this. I want to get the correct settings done on the server side as so far i have'nt set the 'timetolive' parameter on server side services.xml . The client for my service is a .net clientwhich is setting time expire parameter as currenttime+12 hours,but on the server side i am unable to do the same and when the client sends a request with time difference of more than 5 mins ,the service throws the WSDOAll receiver fault . I know that it is to be handled on server side now,please help. My services.xml is as follows : service name=AccountService Description Web Service for saving the account details in Server database /Description messageReceivers messageReceiver mep=http://www.w3.org/2004/08/wsdl/in-only; class=org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver / messageReceiver mep=http://www.w3.org/2004/08/wsdl/in-out; class=org.apache.axis2.rpc.receivers.RPCMessageReceiver/ /messageReceivers parameter name=ServiceObjectSupplier locked=falseorg.apache.axis2.extensions.spring.receivers.SpringAppContextAwareObjectSupplier/parameter parameter name=SpringBeanName locked=falsesendSms/parameter parameter name=InflowSecurity action itemsUsernameToken Timestamp/items passwordCallbackClasscom.knowcross.gmhs.wsdldao.htngmodule.HtngSecurityCallbackHandler/passwordCallbackClass /action /parameter /service Regards, Amit Swaroop Jos Dirksen wrote: Hi, I'm currently trying out some scenarios with Rampart and run into an issue with the Rampart module. When just specifying the timeout security action, this timeout isn't checked by the incoming security handler. Is this correct behaviour? On the serverside I specified the following: parameter name=InflowSecurity action itemsTimestamp/items /action /parameter And on the client side I've configured it like this: parameter name=OutflowSecurity action itemsTimestamp/items timeToLive1/timeToLive /action /parameter When I delay the sending of the message (e.g. by debugging) the message is still accepted at the server even though the ttl has passed. When I debug somewhat deeper into the WSS4J code, I don't see a check there. I hope this is the correct forum to ask this question, if not I'll try at the WSS4J forum. -- View this message in context: http://www.nabble.com/-Axis2--Rampart-WSS4J-timestamp-check-tp6156270p22843553.html Sent from the Axis - User mailing list archive at Nabble.com.
SOAP problem
Hi, I'm using this code to configuer axis engine: public static EngineConfiguration createClientConfig() { SimpleProvider clientConfig = new SimpleProvider(); Handler securitySenderHandler = (Handler) new WSDoAllSender(); securitySenderHandler.setOption(WSHandlerConstants.ACTION, WSHandlerConstants.SIGNATURE); securitySenderHandler.setOption(WSHandlerConstants.USER, cert); securitySenderHandler.setOption(WSHandlerConstants.SIG_KEY_ID, DirectReference); securitySenderHandler.setOption(WSHandlerConstants.MUST_UNDERSTAND, false); securitySenderHandler.setOption(WSHandlerConstants.SIG_PROP_FILE, clientCrypto.properties); securitySenderHandler.setOption(WSHandlerConstants.PW_CALLBACK_CLASS, PWCallback); SimpleChain reqHandler = new SimpleChain(); SimpleChain respHandler = new SimpleChain(); reqHandler.addHandler(securitySenderHandler); Handler pivot = (Handler) new HTTPSender(); Handler transport = new SimpleTargetedChain(reqHandler, pivot, respHandler); clientConfig.deployTransport(HTTPTransport.DEFAULT_TRANSPORT_NAME,transport); return clientConfig; } SOAP envelope im sending lost couple lines in the end of message... Can any body halp me ? Some sugestion? Best regards MO
Need help- with Axis2 1.1
Hi, I have downloaded axis2-1.1.1 to my system I also have jboss-3.0.4_tomcat-4.0.6 installed. Could you please give me the series of steps to be followed to create a web service using axis2-1.1.1. Thanks in advance. Regards, Pricilla
Re: Need help- with Axis2 1.1
Hi Pricilla, Axis2 installation guide[1] describe how to install on a web server like JBoss , then refer Axis2 Quick Start Guide[2] to create your first service. Also if it is possible move to latest Axis2 version like 1.4.1. [1] - http://ws.apache.org/axis2/1_4_1/installationguide.html#servlet_container [2] - http://ws.apache.org/axis2/1_4_1/quickstartguide.html Thanks , On Thu, Apr 2, 2009 at 3:01 PM, pricilla p pricy...@gmail.com wrote: Hi, I have downloaded axis2-1.1.1 to my system I also have jboss-3.0.4_tomcat-4.0.6 installed. Could you please give me the series of steps to be followed to create a web service using axis2-1.1.1. Thanks in advance. Regards, Pricilla -- Sagara Gunathunga Blog - http://ssagara.blogspot.com Web - http://sagaras.awardspace.com/
wsdl2java
OK, looking for something definitive here. I am running Axis 1.4 (Implementation-Version: 1.4 1855 April 22 2006) Trying to convert some wsdl generated from Microsoft WCF to java stubs using wsdl2java, and running into some problems. The WCF side of my team says java has trouble with tree wsdl (wdl:import, xsd:import). I have trouble believing this is true, and assume that wcf is generating non standard wsdl. So, can wsdl2java under Axis 1.4 support tree wsdl? Or am I barking up the wrong... Ed
Adding authentication for a generated client
Hello! I'm new with Axis and WS; I'm trying to build a webservice which requires authentication, only username password (no encryption needed). I wrote a WSDL file and then I generated the java client server classes in eclipse (like with wsdl2java). Now the WS is working but with no authentication. I started following this tutorial: http://www.javaranch.com/journal/200709/web-services-authentication-axis2.htmland now I can get authentication working in the server side (I suppose), adding the rampart module and this code in the services.xml: module ref=rampart / parameter name=InflowSecurity action itemsUsernameToken Timestamp/items passwordCallbackClass tests.security.PasswordCallBackHandler /passwordCallbackClass /action /parameter But I don't know how to add the authentication headers with the generated code in the client side. Someone have some guidelines? Thanks!
RE: Axis2 service and spring problem, can't find Spring's ApplicationContext.
Thanks Sagara. I actually tried that one first but I didn't know which of the suppliers was the correct one so I tried both. In my mail I pasted the exception from SpringAppContextAwareObjectSupplier twice by accident. When using SpringServletContextObjectSupplier I got a No bean named 'MyServ' exception, but when I added: bean id=MyServ class=xyz.MyServ /bean to the context.xml file the error went away. So now it deploys and runs without errors, I also got the test string back in my ws-client. But later when I tried using the context I get from ApplicationContextHolder.getContext() I found that it has value null??? Anyone know why? -Az. (I have added the information about my files written in my first mail since this might be needed to see the new error.) MyServ.java - . import org.apache.axis2.extensions.spring.receivers.ApplicationContextHolder; . import org.springframework.context.ApplicationContext; . public class MyServ { . public String serExe() { . ApplicationContext ctx = ApplicationContextHolder.getContext(); . return test; } } The services.xml: - serviceGroup service name=MyServ description blabla /description parameter name=ServiceObjectSupplier org.apache.axis2.extensions.spring.receivers. SpringServletContextObjectSupplier/parameter parameter name=SpringBeanNameMyServ/parameter parameter name=ServiceClass locked=falsexyz.MyServ/parameter operation name=serExe messageReceiver class=org.apache.axis2.rpc.receivers.RPCMessageReceiver/ /operation /service /serviceGroup Added to rest of the properties etc in the context.xml file: - bean id=T2Wrapper class=xyz.T2Wrapper /bean The web.xml: !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; web-app display-nameBlabla/display-name servlet servlet-nameAxisServlet/servlet-name display-nameApache-Axis Servlet/display-name servlet-class org.apache.axis2.transport.http.AxisServlet /servlet-class load-on-startup1/load-on-startup /servlet servlet-mapping servlet-nameAxisServlet/servlet-name url-pattern/services/*/url-pattern /servlet-mapping context-param param-namecontextConfigLocation/param-name param-value/WEB-INF/context.xml/param-value /context-param context-param param-namecontextClass/param-name param-value ( path of a specific kind of WebApplicationContext class which the SpringAppl expects...) /param-value /context-param listener listener-class org.springframework.web.context.ContextLoaderListener /listener-class /listener /web-app _ Få nye Windows Live™ Messenger. http://download.live.com/messenger
AW: Adding authentication for a generated client
Hi Eduard, you can try this tutorial: http://wso2.org/library/240 hope that helps. best regards Werner Von: Eduard Martínez martinez.ber...@gmail.com An: axis-user@ws.apache.org Gesendet: Donnerstag, den 2. April 2009, 16:36:14 Uhr Betreff: Adding authentication for a generated client Hello! I'm new with Axis and WS; I'm trying to build a webservice which requires authentication, only username password (no encryption needed). I wrote a WSDL file and then I generated the java client server classes in eclipse (like with wsdl2java). Now the WS is working but with no authentication. I started following this tutorial: http://www.javaranch.com/journal/200709/web-services-authentication-axis2.html and now I can get authentication working in the server side (I suppose), adding the rampart module and this code in the services.xml: module ref=rampart / parameter name=InflowSecurity action itemsUsernameToken Timestamp/items passwordCallbackClass tests.security.PasswordCallBackHandler /passwordCallbackClass /action /parameter But I don't know how to add the authentication headers with the generated code in the client side. Someone have some guidelines? Thanks!
Re: Axis2 service and spring problem, can't find Spring's ApplicationContext.
Hi Azazel , But later when I tried using the context I get from ApplicationContextHolder.getContext() I found that it has value null??? Anyone know why? Here, how you try to use context .and can you provide error trace you got ? i cant get any clue with supplied details . . ApplicationContext ctx = ApplicationContextHolder.getContext(); I don't think you need to have this line to access SpringContext explicitly , because MyServ is already a Spring manged bean. if you want to access any other bean inside MyServ use Spring injection instead of access through ApplicationContextHolder. as a example if you want to access dbService bean , just add setter and getter methods toMyServ class and use appContext.xml file to inject that dbService bean id=MyServ class=xyz.MyServ property name=dbService ref=dbService/ /bean I think you already familiar with this approach :) with Axis2 you can use Spring programing approach without any modification. I think this will resolve your problem too. Thanks , -- Sagara Gunathunga Blog - http://ssagara.blogspot.com Web - http://sagaras.awardspace.com/
Re: Axis2 service and spring problem, can't find Spring's ApplicationContext.
On Thu, Apr 2, 2009 at 12:01 PM, Azazel Se azazel...@hotmail.com wrote: Thanks Sagara. I actually tried that one first but I didn't know which of the suppliers was the correct one so I tried both. In my mail I pasted the exception from SpringAppContextAwareObjectSupplier twice by accident. When using SpringServletContextObjectSupplier I got a No bean named 'MyServ' exception, but when I added: bean id=MyServ class=xyz.MyServ /bean to the context.xml file the error went away. So now it deploys and runs without errors, I also got the test string back in my ws-client. But later when I tried using the context I get from ApplicationContextHolder.getContext() I found that it has value null??? Anyone know why? ApplicationContextHolder.getContext() isn't needed when using SpringServletContextObjectSupplier. If spring and axis2 are working together, you are done. You have to configure Spring to use ApplicationContextHolder, otherwise it will return null values. - R
RE: Axis2 service and spring problem, can't find Spring's ApplicationContext.
From: robertlazar...@gmail.com ApplicationContextHolder.getContext() isn't needed when using SpringServletContextObjectSupplier. If spring and axis2 are working together, you are done. You have to configure Spring to use ApplicationContextHolder, otherwise it will return null values. - R From: sagara.gunathu...@gmail.com To: axis-user@ws.apache.org Here, how you try to use context .and can you provide error trace you got ? i cant get any clue with supplied details . . ApplicationContext ctx = ApplicationContextHolder.getContext(); I don't think you need to have this line to access SpringContext explicitly , because MyServ is already a Spring manged bean. if you want to access any other bean inside MyServ use Spring injection instead of access through ApplicationContextHolder. Hi, thanks for the replies. I have an application which I didn't make which uses spring, it has an API which hides the details and preferably I don't add any more stuff to it. The goal is to just use a few of the methods and get returns as normal and not interact directly with spring. I have never used Spring before so my knowledge about the innerworkings is small but if I get the API to work I shouldn't need to either. The springappl needs the context at initiating. I have tested it in a jsp file and it works, but I want to move it to a web service. In the jsp file I had the same context stuff added to the web.xml and this is in the jsp file: MyApplWithSpring ap = new MyApplWithSpring(WebApplicationContextUtils.getWebApplicationContext(getServletContext())); This worked and I could use some of its methods afterwards. So I thought it would work in the web service as well if I used ApplicationContextHolder.getContext() and used new MyApplWithSpring(ApplicationContextHolder.getContext()). If possible how do I configure spring to use the ApplicationContextHolder so that it isn't null? Or is there any other(/better) way I can do this? -Az. New java class, only added the fourth line and this gives an error since con is null: --- public class MyServ { public String serExe() { ApplicationContext con = ApplicationContextHolder.getContext(); MyApplWithSpring ap = new MyApplWithSpring(con); return testWithSpringAppl; } } Exception in eclipse when running client: --- Exception in thread main org.apache.axis2.AxisFault: Cannot attach a profile to a null context at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163) at xyz.MyServStub.serExe(MyServStub.java:183) at xyz.MyServClient.main(MyServClient.java:17) Output of Exception at runtime in the tomcat server: -- ERROR - RPCMessageReceiver.invokeBusinessLogic(157) | Cannot attach a profile to a null context java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.jav a:165) at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic (RPCMessageReceiver.java:102) at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusines sLogic(AbstractInOutMessageReceiver.java:40) at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMe ssageReceiver.java:100) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReq uest(HTTPTransportUtils.java:275) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:1 33) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:128)
Re: Axis2 service and spring problem, can't find Spring's ApplicationContext.
As mentioned in previous mails ApplicationContextHolder.getContext() is not required to handle this , i think reading some Spring docs will helpful to you because this is a problem with the the way you retrieve beans from spring context. First create your service as a POJO service and configure it within SpringContext , then as you already did ,expose this service bean as a web service using Axis2 SpringServletContextObjectSupplier in this case you don't need to modify your java codes to expose your spring bean as a web service. Thanks , On Thu, Apr 2, 2009 at 10:18 PM, Azazel Se azazel...@hotmail.com wrote: From: robertlazar...@gmail.com ApplicationContextHolder.getContext() isn't needed when using SpringServletContextObjectSupplier. If spring and axis2 are working together, you are done. You have to configure Spring to use ApplicationContextHolder, otherwise it will return null values. - R From: sagara.gunathu...@gmail.com To: axis-user@ws.apache.org Here, how you try to use context .and can you provide error trace you got ? i cant get any clue with supplied details . . ApplicationContext ctx = ApplicationContextHolder.getContext(); I don't think you need to have this line to access SpringContext explicitly , because MyServ is already a Spring manged bean. if you want to access any other bean inside MyServ use Spring injection instead of access through ApplicationContextHolder. Hi, thanks for the replies. I have an application which I didn't make which uses spring, it has an API which hides the details and preferably I don't add any more stuff to it. The goal is to just use a few of the methods and get returns as normal and not interact directly with spring. I have never used Spring before so my knowledge about the innerworkings is small but if I get the API to work I shouldn't need to either. The springappl needs the context at initiating. I have tested it in a jsp file and it works, but I want to move it to a web service. In the jsp file I had the same context stuff added to the web.xml and this is in the jsp file: MyApplWithSpring ap = new MyApplWithSpring(WebApplicationContextUtils.getWebApplicationContext(getServletContext())); This worked and I could use some of its methods afterwards. So I thought it would work in the web service as well if I used ApplicationContextHolder.getContext() and used new MyApplWithSpring(ApplicationContextHolder.getContext()). If possible how do I configure spring to use the ApplicationContextHolder so that it isn't null? Or is there any other(/better) way I can do this? -Az. New java class, only added the fourth line and this gives an error since con is null: --- public class MyServ { public String serExe() { ApplicationContext con = ApplicationContextHolder.getContext(); MyApplWithSpring ap = new MyApplWithSpring(con); return testWithSpringAppl; } } Exception in eclipse when running client: --- Exception in thread main org.apache.axis2.AxisFault: Cannot attach a profile to a null context at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163) at xyz.MyServStub.serExe(MyServStub.java:183) at xyz.MyServClient.main(MyServClient.java:17) Output of Exception at runtime in the tomcat server: -- ERROR - RPCMessageReceiver.invokeBusinessLogic(157) | Cannot attach a profile to a null context java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.jav a:165) at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic (RPCMessageReceiver.java:102) at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusines sLogic(AbstractInOutMessageReceiver.java:40) at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMe ssageReceiver.java:100) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostReq uest(HTTPTransportUtils.java:275) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:1 33)
Re: Axis2 service and spring problem, can't find Spring's ApplicationContext.
On Thu, Apr 2, 2009 at 1:48 PM, Azazel Se azazel...@hotmail.com wrote: From: robertlazar...@gmail.com ApplicationContextHolder.getContext() isn't needed when using SpringServletContextObjectSupplier. If spring and axis2 are working together, you are done. You have to configure Spring to use ApplicationContextHolder, otherwise it will return null values. - R From: sagara.gunathu...@gmail.com To: axis-user@ws.apache.org Here, how you try to use context .and can you provide error trace you got ? i cant get any clue with supplied details . . ApplicationContext ctx = ApplicationContextHolder.getContext(); I don't think you need to have this line to access SpringContext explicitly , because MyServ is already a Spring manged bean. if you want to access any other bean inside MyServ use Spring injection instead of access through ApplicationContextHolder. Hi, thanks for the replies. I have an application which I didn't make which uses spring, it has an API which hides the details and preferably I don't add any more stuff to it. The goal is to just use a few of the methods and get returns as normal and not interact directly with spring. I have never used Spring before so my knowledge about the innerworkings is small but if I get the API to work I shouldn't need to either. The springappl needs the context at initiating. I have tested it in a jsp file and it works, but I want to move it to a web service. In the jsp file I had the same context stuff added to the web.xml and this is in the jsp file: MyApplWithSpring ap = new MyApplWithSpring(WebApplicationContextUtils.getWebApplicationContext(getServletContext())); This worked and I could use some of its methods afterwards. So I thought it would work in the web service as well if I used ApplicationContextHolder.getContext() and used new MyApplWithSpring(ApplicationContextHolder.getContext()). If possible how do I configure spring to use the ApplicationContextHolder so that it isn't null? Or is there any other(/better) way I can do this? -Az. So the springappl you didn't write requires an ApplicationContext reference, even though you are successfully using SpringServletContextObjectSupplier that doesn't really require an ApplicationContext reference? If so, I'll show you how to do it. - R
Re: Axis2 service and spring problem, can't find Spring's ApplicationContext.
On Thu, Apr 2, 2009 at 4:05 PM, Azazel Se azazel...@hotmail.com wrote: Date: Thu, 2 Apr 2009 15:01:48 -0300 Subject: Re: Axis2 service and spring problem, can't find Spring's ApplicationContext. From: robertlazar...@gmail.com To: axis-user@ws.apache.org On Thu, Apr 2, 2009 at 1:48 PM, Azazel Se azazel...@hotmail.com wrote: From: robertlazar...@gmail.com ApplicationContextHolder.getContext() isn't needed when using SpringServletContextObjectSupplier. If spring and axis2 are working together, you are done. You have to configure Spring to use ApplicationContextHolder, otherwise it will return null values. - R From: sagara.gunathu...@gmail.com To: axis-user@ws.apache.org Here, how you try to use context .and can you provide error trace you got ? i cant get any clue with supplied details . . ApplicationContext ctx = ApplicationContextHolder.getContext(); I don't think you need to have this line to access SpringContext explicitly , because MyServ is already a Spring manged bean. if you want to access any other bean inside MyServ use Spring injection instead of access through ApplicationContextHolder. Hi, thanks for the replies. I have an application which I didn't make which uses spring, it has an API which hides the details and preferably I don't add any more stuff to it. The goal is to just use a few of the methods and get returns as normal and not interact directly with spring. I have never used Spring before so my knowledge about the innerworkings is small but if I get the API to work I shouldn't need to either. The springappl needs the context at initiating. I have tested it in a jsp file and it works, but I want to move it to a web service. In the jsp file I had the same context stuff added to the web.xml and this is in the jsp file: MyApplWithSpring ap = new MyApplWithSpring(WebApplicationContextUtils.getWebApplicationContext(getServletContext())); This worked and I could use some of its methods afterwards. So I thought it would work in the web service as well if I used ApplicationContextHolder.getContext() and used new MyApplWithSpring(ApplicationContextHolder.getContext()). If possible how do I configure spring to use the ApplicationContextHolder so that it isn't null? Or is there any other(/better) way I can do this? -Az. So the springappl you didn't write requires an ApplicationContext reference, even though you are successfully using SpringServletContextObjectSupplier that doesn't really require an ApplicationContext reference? If so, I'll show you how to do it. - R At the bottom are the first few lines of the code that works in eclipse. The problems arise when wanting to deploy to axis2 and tomcat. The application I am making a small wrapper for is very big and complex and the context.xml imports several other xml files. The goal of the web service is to receive a string from the client, use the application to do some stuff with a file and the string as input, then return the results to the client. The application uses spring, hibernate etc. -Az. //Create Platform. ApplicationContext context = new RavenAwareClassPathXmlApplicationContext(context.xml); TavernaBaseProfile profile = new TavernaBaseProfile(context); //Get workflow parser, load workflow. WorkflowParser parser = profile.getWorkflowParser(); URL workflowURL = new URL(http://foo.com/workflow.xml;); Dataflow workflow = parser.createDataflow(workflowURL); Apart from this code, is spring and axis2 running together in your web service? I thought you said it was. I think I know what your are asking for, but without knowing what TavernaBaseProfile is doing, I'd be concerned that it creates two separate Spring worlds in your app - you probably don't want that. Anyways, with that caveat, if you just need ApplicationContext to pass into TavernaBaseProfile , I would do the following: Keep axis2 and spring as is, since its working. The idea behind the axis2 ApplicationContextHolder is a known way to get an ApplicationContext, and can be used outside axis2. So I think you should create your own. Its easy, and it seems far less confusing, at least to me, to use your own ApplicationContextHolder outside of axis2 when using SpringServletContextObjectSupplier. So you'd need this xml in your Spring config: !-- Use this trick to get access to Spring beans in junit and other places that are not spring aware -- bean id=applicationContext class=mypackage.spring.ApplicationContextHolder / And this class in your app: package mypackage.spring; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; /** Implementation of a Spring interface who is configured in Spring's * applicationContext.xml or some other Spring type of way. This class * and the spring bean
RE: Axis2 service and spring problem, can't find Spring's ApplicationContext.
Hi. Thanks alot! When I created my own ApplicationContextHolder everything worked. Thanks for all your help, much appreciated after this has taken me alot more time then it probably should have.. :) -Az. Apart from this code, is spring and axis2 running together in your web service? I thought you said it was. I think I know what your are asking for, but without knowing what TavernaBaseProfile is doing, I'd be concerned that it creates two separate Spring worlds in your app - you probably don't want that. Anyways, with that caveat, if you just need ApplicationContext to pass into TavernaBaseProfile , I would do the following: Keep axis2 and spring as is, since its working. The idea behind the axis2 ApplicationContextHolder is a known way to get an ApplicationContext, and can be used outside axis2. So I think you should create your own. Its easy, and it seems far less confusing, at least to me, to use your own ApplicationContextHolder outside of axis2 when using SpringServletContextObjectSupplier. So you'd need this xml in your Spring config: !-- Use this trick to get access to Spring beans in junit and other places that are not spring aware -- bean id=applicationContext class=mypackage.spring.ApplicationContextHolder / And this class in your app: package mypackage.spring; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; /** Implementation of a Spring interface who is configured in Spring's * applicationContext.xml or some other Spring type of way. This class * and the spring bean needed to wire it could be used as an alternative * to getting the ApplicationContext from the ServletContext. It also can * be used to get access to spring beans in places like junit that are not * spring aware. */ public class ApplicationContextHolder implements ApplicationContextAware { private static ApplicationContext appCtx; public ApplicationContextHolder() {} /** Spring supplied interface method for injecting app context. */ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { appCtx = applicationContext; } /** Access to spring wired beans. */ public static ApplicationContext getContext() { return appCtx; } } Then instead of: ApplicationContext context = new RavenAwareClassPathXmlApplicationContext(context.xml); Do this: ApplicationContext ctx = ApplicationContextHolder.getContext(); TavernaBaseProfile profile = new TavernaBaseProfile(context); Good luck, Robert _ Ditt liv. Dine ting. Alt på ett sted med Windows Live™. http://windowslive.no
unregister
unregister