AXIOM - remove namespace
Hi, I'm trying to remove a namespace from a SOAPBody element. Unfortunately, without any luck so far. Here is what I do: OMElement request = ... OMNamespace ns = OMAbstractFactory.getOMFactory().createOMNamespace("", ""); request.declareNamespace(ns); Though, when I print the request the namespace is still the there. Thanks in advance, Alex
Re: remove element from soap body
Hi Isuru, Thanks for your help. It works! In case someone else encounters a similar issue, that's how I did it (removes the very first element of the SOAP body): SOAPBody body = oMessageContext.getEnvelope().getBody(); OMElement first = body.getFirstElement(); OMElement second = first.getFirstElement(); // remove the first element from the body first.detach(); // add the request element to the body body.addChild(second); Regards, -Alex Isuru Suriarachchi wrote: Hi Alex, Use omElement.detach() method.. Thanks, ~Isuru On Mon, Nov 9, 2009 at 2:33 PM, Alexander Rosemann mailto:alexander.rosem...@gmail.com>> wrote: Hi, I was wondering what's the best way to alter a soap body within a handler. I have the soap body (SOAPBody body = msgCtx.getEnvelope().getBody();) and can navigate though it's elements but don't know how to alter (i.e. remove) a certain element. Since I haven't found anything on the web, I was wondering whether somebody tried to achieve the same and could point me into the right direction. I'm using Axis2 1.4.1. Thanks in advance, Alex -- Senior Software Engineer, WSO2 Inc. http://wso2.org/ Blog : http://isurues.wordpress.com/ -- DI(FH) Alexander Rosemann open source based software solutions Naunspitzweg 3 | 6341 Ebbs | Austria mobile: +43-681-10337082 | email: alexander.rosem...@gmail.com
remove element from soap body
Hi, I was wondering what's the best way to alter a soap body within a handler. I have the soap body (SOAPBody body = msgCtx.getEnvelope().getBody();) and can navigate though it's elements but don't know how to alter (i.e. remove) a certain element. Since I haven't found anything on the web, I was wondering whether somebody tried to achieve the same and could point me into the right direction. I'm using Axis2 1.4.1. Thanks in advance, Alex
sending an application/json formatted request
Hi, I'm trying for a while now to get axis2 to accept incoming application/json requests (JSONMessageFormatter/ JSONOMBuilder). I always get a "java.lang.IllegalArgumentException: The MessageContext does not have an associated SOAPFault" on the client side and a huge json formatted soap error on the server side: "ERROR http-9080-Processor24 org.apache.axis2.engine.AxisEngine - The endpoint reference (EPR) for the Operation not found is http://localhost:9082/sm62/services/echo/echo and the WSA Action = null". The exact same service works fine when sending application/xml requests though. I've configured both the client axis.xml and the server axis.xml according to the axis2.xml file that comes with JSONIntegrationTest.java. The only difference is that I've disabled the transportReceiver since axis runs within tomcat. I'm using axis2 1.4.1 embedded in another web-app hosted by tomcat 5.5. client code: private static OMElement payload() throws Exception { OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace ns = fac.createOMNamespace("", ""); OMElement request = fac.createOMElement("request", ns); request.addAttribute("attr", "some data", ns); return request; } private static void runAxisClient() { try { File configFile = new File("resources/axis2.xml"); ConfigurationContext cfgCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(null, configFile.getAbsolutePath()); ServiceClient client = new ServiceClient(cfgCtx, null); Options options = new Options(); options.setTo(new EndpointReference("http://localhost:9080/myapp/services/echo/echo";)); options.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/json"); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setProperty(Constants.Configuration.HTTP_METHOD, Constants.Configuration.HTTP_METHOD_POST); client.setOptions(options); OMElement response = client.sendReceive(payload()); System.out.println("response: " + response); } catch (Exception e) { e.printStackTrace(); } } Any pointers are much appreciated. Especially a hint why axis is telling me that the endpoint is wrong although it's working ok for xml messages? Thanks in advance, Alex
Re: Is it safe to remove axis-web JSPs?
Hi Joe, I've removed the entire JSP stuff and axis 1.4.1 is still working as usual. hth, Alex Joe Smithian wrote: Hi All, I am working on a web services application using AXIS2. The axis-web includes many JSPs for online management of the web services (upload, activate, inactivate, etc.) I don't need these web-admin functionalities; I am wondering if I can remove them without affecting the web services appliacation. The only thing I need is displaying list of available services and thier status (active or not) and acessing the WSDL. Please comment. Thanks Joe -- DI(FH) Alexander Rosemann open source based software solutions Naunspitzweg 3 | 6341 Ebbs | Austria mobile: +43-681-10337082 | email: alexander.rosem...@gmail.com *** Your partner in building cutting edge open source based software solutions ***
ServiceGroupContext is null
Hi, I'm trying to use the ServiceGroupContext to share data among a Handler and Services. I've implemented an AuthenticationDispatcher (extends AbstractHandler) and added it to the security phase of the InFlow phase order. The AuthenticationDispatcher gets called each time a request comes in. Within the AuthenticationDispatcher I'm getting the ServiceGroupHandler from the MessageContext parameter. Unfortunately calling, ServiceGroupContext sgc = mc.getServiceGroupContext(); returns always null. Afaik is the ServiceGroupContext the right place to share data between services. All services are in one aar-file and declared within a serviceGroup. The scope of each service is set to application. I'm using axis2-1.4.1 deployed as part of a webapp running in Tomcat 5.5. Any pointers are much appreciated. Regards, Alex
Re: Authentication for non SOAP messages
Would it be feasible to throw an AxisFaul in the handler? Would the AxisFault be able to return an error XML message to the client? Another question where I'm uncertain is where should I store the flag that indicates a client has been authenticated? Would the ServiceGroupContext be the appropriate place for that? Any pointers into the right direction are much appreciated. Thanks, Alex Alexander Rosemann wrote: I've added a handler to the security phase in my axis2.xml. The handler gets called each time a request comes in. I'm just puzzled how I can directly send a response message in case the user has not logged in first. Cheers, Alex Martin Gainty wrote: from the HandlerExecution test harness i've seen this depends on assigned PHASE package org.apache.axis2.engine; public class HandlerExecutionTest extends LocalTestCase { *... *private void registerOperationLevelHandlers(AxisOperation operation) { ArrayList operationSpecificPhases = new ArrayList(); operationSpecificPhases.add(new Phase(PhaseMetadata.PHASE_POLICY_DETERMINATION)); operation.setRemainingPhasesInFlow(operationSpecificPhases); ArrayList phaseList = operation.getRemainingPhasesInFlow(); for (int i = 0; i < phaseList.size(); i++) { Phase operationSpecificPhase = (Phase)phaseList.get(i); if (PhaseMetadata.PHASE_POLICY_DETERMINATION .equals(operationSpecificPhase.getPhaseName())) { operationSpecificPhase.addHandler(firstOperationInHandler); operationSpecificPhase.addHandler(middleOperationInHandler); operationSpecificPhase.addHandler(new TestHandler("In6")); } } operationSpecificPhases = new ArrayList(); operationSpecificPhases.add(new Phase(PhaseMetadata.PHASE_POLICY_DETERMINATION)); operation.setPhasesOutFlow(operationSpecificPhases); phaseList = operation.getPhasesOutFlow(); for (int i = 0; i < phaseList.size(); i++) { Phase operationSpecificPhase = (Phase)phaseList.get(i); if (PhaseMetadata.PHASE_POLICY_DETERMINATION .equals(operationSpecificPhase.getPhaseName())) { operationSpecificPhase.addHandler(new TestHandler("Out1")); operationSpecificPhase.addHandler(middleOperationOutHandler); operationSpecificPhase.addHandler(new TestHandler("Out3")); } } } where PHASES are broken out to package org.apache.axis2.phaseresolver; public class PhaseMetadata { // INFLOW public static final String PHASE_TRANSPORTIN = "TransportIn"; public static final String PHASE_PRE_DISPATCH = "PreDispatch"; public static final String PHASE_POST_DISPATCH = "PostDispatch"; public static final String PHASE_POLICY_DETERMINATION = "PolicyDetermination"; public static final String PHASE_MESSAGE_PROCESSING = "MessageProcessing"; // OUTFLOW public static final String PHASE_MESSAGE_OUT = "MessageOut"; public static final String PHASE_DISPATCH = "Dispatch"; public static final String PHASE_TRANSPORT_OUT = "TransportOut"; public static final String TRANSPORT_PHASE = "TRANSPORT"; which phase would you be attaching your handler to ? Martin __ Disclaimer and Confidentiality/Verzicht und Vertraulichkeitanmerkung / Note de déni et de confidentialité This message is confidential. If you should not be the intended receiver, then we ask politely to report. Each unauthorized forwarding or manufacturing of a copy is inadmissible. This message serves only for the exchange of information and has no legal binding effect. Due to the easy manipulation of emails we cannot take responsibility over the the contents. Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. > Date: Sun, 12 Apr 2009 16:57:24 +0200 >
Re: Authentication for non SOAP messages
> are allowed to access any of the services. > > My idea is to implement a simple handler which checks whether an > authentication flag has been set in the ServiceGroupContext. In case > it's not available the only service accessible should be the > authentication service and an error response message should be sent. If > the flag has been set, all other services can be accessed until > ServiceGroupContext timed out or the client logged off. > > What I can't see is how to send an error response from within a handler. > > Any pointers, input, and additional suggestions are highly welcome. > > Thanks, > Alex > > > > Rediscover Hotmail®: Now available on your iPhone or BlackBerry Check it out. <http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Mobile1_042009> -- DI(FH) Alexander Rosemann open source based software solutions Naunspitzweg 3 | 6341 Ebbs | Austria mobile: +43-681-10337082 | email: alexander.rosem...@gmail.com *** Your partner in building cutting edge open source based software solutions ***
Authentication for non SOAP messages
Hi, I've created a bunch of Web services, including an authentication service. All services consume and return raw XML messages (no SOAP) which works fine. Now I would like to force clients to authenticate themselves before they are allowed to access any of the services. My idea is to implement a simple handler which checks whether an authentication flag has been set in the ServiceGroupContext. In case it's not available the only service accessible should be the authentication service and an error response message should be sent. If the flag has been set, all other services can be accessed until ServiceGroupContext timed out or the client logged off. What I can't see is how to send an error response from within a handler. Any pointers, input, and additional suggestions are highly welcome. Thanks, Alex
Re: Java2WSDL and abstract classes
Hi Dennis, Thanks for the hint. I'll give it a shot when I have to implement another service. This time I took the route developing the xml manually which works fine now. Thanks, -Alex Dennis Sosnoski wrote: Hi Alex, You'll probably have a much easier time of it if you use Jibx2Wsdl (included in the current 1.2.1 release of JiBX) rather than Java2WSDL. Jibx2Wsdl has a number of nice features, including Java 5 typed collection and enum support, automatic JavaDoc extraction to WSDL and schema documentation, and extensive customizations support. To include extra classes in your data model (such as the subclasses in your example), you just need to specify the extra classes on the command line using an '-x' argument flag. See the /examples/jibx2wsdl/example3 code and build for an example doing just this, using an interface rather than an abstract class. Using Jibx2Wsdl in no way commits you to using JiBX for your services (though it's easy to do so, since you get JiBX bindings out of Jibx2Wsdl as well as the WSDL and schema). See the Jibx2Wsdl documentation on the JiBX site (still somewhat limited, unfortunately) for details: http://jibx.sourceforge.net/fromcode/jibx2wsdl.html - Dennis Dennis M. Sosnoski SOA and Web Services in Java Training and Consulting http://www.sosnoski.com - http://www.sosnoski.co.nz Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 Alexander Rosemann wrote: Hi, I know, this has been asked before, though I couldn't find an answer to it. I'm busy fiddling around with the Java2WSDL ant task shipped with Axis2. The tool works fine until I try to generate the WSDL from an abstract class. Having an abstract class called Animal and a subclass Dog, it creates the schema for the Animal but misses out on the Dog type. I presume I just can't see what parameter has to be set to get this going. Any pointers that lead to a resolution of my issue are much appreciated. Thanks, Alex -- DI(FH) Alexander Rosemann open source based software solutions Naunspitzweg 3 | 6341 Ebbs | Austria mobile: +43-681-10337082 | email: alexander.rosem...@gmail.com *** Your partner in building cutting edge open source based web applications ***
Re: Java2WSDL and abstract classes
Hi Sagara, Sagara Gunathunga wrote: Hi Alex, AFAIK there is no special parameter required for this , according to method signatures of your service class, Java2WSDL generate correct schema for in/out messages . in your case it should generates types as follow. - - Anyway can you post method signatures of your service class...? Thanks , That's what I get from running Java2WSDL: http://.../xsd"; targetNamespace="http://..."; attributeFormDefault="qualified" elementFormDefault="qualified"> http://..."/> type="ax22:Animal" nillable="true"/> http://.../xsd"; attributeFormDefault="qualified" elementFormDefault="qualified"> The animal type is there. That's my service class: public class AnimalService { public Animal getAnimal() { return new Dog(); } } Thanks four help Sagara! -Alex
Java2WSDL and abstract classes
Hi, I know, this has been asked before, though I couldn't find an answer to it. I'm busy fiddling around with the Java2WSDL ant task shipped with Axis2. The tool works fine until I try to generate the WSDL from an abstract class. Having an abstract class called Animal and a subclass Dog, it creates the schema for the Animal but misses out on the Dog type. I presume I just can't see what parameter has to be set to get this going. Any pointers that lead to a resolution of my issue are much appreciated. Thanks, Alex
Java2WSDL and abstract classes
Hi, I know, this has been asked before, though I couldn't find an answer to my problem. I'm busy fiddling around with the Java2WSDL ant task shipped with Axis2. The tool works fine until I tried to generate the WSDL from an abstract class. Having an abstract class called Animal and a subclass Dog, it creates the schema for the Animal but misses out on the Dog type. I presume I just can't see what parameter has to be set to get this thing going. Any pointers that lead to a resolution of my issue are much appreciated. Cheers, Alex