1 22 package org.objectweb.petals.binding.axis2.listener.soap; 23 24 import java.io.IOException ; 25 import java.io.OutputStream ; 26 27 import javax.jbi.component.ComponentContext; 28 import javax.jbi.servicedesc.ServiceEndpoint; 29 30 import org.apache.axis2.AxisFault; 31 import org.apache.axis2.description.AxisService; 32 import org.apache.axis2.engine.AxisConfiguration; 33 import org.objectweb.petals.component.common.util.WSDLHelper; 34 import org.w3c.dom.Document ; 35 36 46 public class PetalsAxisService extends AxisService { 47 48 private ComponentContext componentContext; 49 50 private ServiceEndpoint endpoint; 51 52 59 public PetalsAxisService(String name, ComponentContext componentContext, 60 ServiceEndpoint endpoint) { 61 super(name); 62 this.componentContext = componentContext; 63 this.endpoint = endpoint; 64 } 65 66 72 @Override 73 public void printWSDL(OutputStream out, String requestIP, String servicePath) 74 throws AxisFault { 75 try { 76 Document document = componentContext 77 .getEndpointDescriptor(endpoint); 78 if (document == null) { 79 printWSDLError(out); 80 } else { 81 WSDLHelper.printWSDL(document, out); 82 } 83 } catch (Exception e) { 84 throw new AxisFault(e); 85 } 86 } 87 88 91 @Override 92 public void printWSDL2(OutputStream out, String requestIP, String servicePath) throws AxisFault { 93 printWSDL(out, requestIP, servicePath); 94 } 95 96 102 private void printWSDLError(OutputStream out) throws AxisFault { 103 try { 104 String wsdlntfound = "<error>" 105 + "<description>Unable to get WSDL for this service</description>" 106 + "<reason>The PEtALS endpoint did not returns its descriptor. </reason>" 107 + "</error>"; 108 out.write(wsdlntfound.getBytes()); 109 out.flush(); 110 out.close(); 111 } catch (IOException e) { 112 throw new AxisFault(e); 113 } 114 } 115 } 116 | Popular Tags |