/** * Create spine from an existing OM tree * * @param envelope * @param style Style * @param indirection (0 or 1) indicates location of body blocks * @throws WebServiceException */ public XMLSpineImpl(SOAPEnvelope envelope, Style style, int indirection, Protocol protocol) throws WebServiceException { super(); this.style = style; this.indirection = indirection; this.protocol = protocol; init(envelope); // If null, detect protocol from soap namespace if (protocol == null) { if (root.getNamespace().getNamespaceURI() .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { this.protocol = Protocol.soap11; } else if (root.getNamespace().getNamespaceURI() .equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { this.protocol = Protocol.soap12; } } }
public QName getOperationElement() throws WebServiceException { try { if (style != Style.RPC) { return null; } switch (contentType) { case OM: return ((org.apache.axiom.soap.SOAPEnvelope)content).getBody(). getFirstElement().getQName(); case SPINE: return ((XMLSpine)content).getOperationElement(); case SOAPENVELOPE: Iterator it = ((SOAPEnvelope)content).getBody().getChildElements(); while (it.hasNext()) { Node node = (Node)it.next(); if (node instanceof SOAPElement) { Name name = ((SOAPElement)node).getElementName(); return new QName(name.getURI(), name.getLocalName(), name.getPrefix()); } } } return null; } catch (SOAPException se) { throw ExceptionFactory.makeWebServiceException(se); } }
@Override public @Nullable QName getRequestPayloadName() { if (emptyRequestPayload) return null; if (requestPayloadName != null) return requestPayloadName; if(style.equals(Style.RPC)){ String ns = getRequestNamespace() != null ? getRequestNamespace() : name.getNamespaceURI(); requestPayloadName = new QName(ns, name.getLocalPart()); return requestPayloadName; }else{ QName inMsgName = operation.getInput().getMessage().getName(); EditableWSDLMessage message = messages.get(inMsgName); for(EditableWSDLPart part:message.parts()){ ParameterBinding binding = getInputBinding(part.getName()); if(binding.isBody()){ requestPayloadName = part.getDescriptor().name(); return requestPayloadName; } } //Its empty payload emptyRequestPayload = true; } //empty body return null; }
@Override public @Nullable QName getResponsePayloadName() { if (emptyResponsePayload) return null; if (responsePayloadName != null) return responsePayloadName; if(style.equals(Style.RPC)){ String ns = getResponseNamespace() != null ? getResponseNamespace() : name.getNamespaceURI(); responsePayloadName = new QName(ns, name.getLocalPart()+"Response"); return responsePayloadName; }else{ QName outMsgName = operation.getOutput().getMessage().getName(); EditableWSDLMessage message = messages.get(outMsgName); for(EditableWSDLPart part:message.parts()){ ParameterBinding binding = getOutputBinding(part.getName()); if(binding.isBody()){ responsePayloadName = part.getDescriptor().name(); return responsePayloadName; } } //Its empty payload emptyResponsePayload = true; } //empty body return null; }
/** * Create a lightweight representation of this protocol (i.e. the Envelope, Header and Body) * * @param protocol Protocol * @param style Style * @param indirection (0 or 1) indicates location of body blocks * @param initialPayload (OMElement or null...used to add rest payload) */ public XMLSpineImpl(Protocol protocol, Style style, int indirection, OMElement payload) { super(); this.protocol = protocol; this.style = style; this.indirection = indirection; soapFactory = _getFactory(protocol); root = _createEmptyEnvelope(style, soapFactory); if (payload != null) { ((SOAPEnvelope)root).getBody().addChild(payload); } }
/** * Create an emtpy envelope * * @param protocol * @param style * @param factory * @return */ private static SOAPEnvelope _createEmptyEnvelope(Style style, SOAPFactory factory) { SOAPEnvelope env = factory.createSOAPEnvelope(); // Add an empty body and header factory.createSOAPBody(env); factory.createSOAPHeader(env); // Create a dummy operation element if this is an rpc message if (style == Style.RPC) { OMNamespace ns = factory.createOMNamespace("", ""); factory.createOMElement("PLACEHOLDER_OPERATION", ns, env.getBody()); } return env; }
/** * XMLPart should be constructed via the XMLPartFactory. This constructor creates an XMLPart from * the specified root. * * @param root * @param protocol (if null, the soap protocol is inferred from the namespace) * @throws WebServiceException */ XMLPartBase(OMElement root, Protocol protocol) throws WebServiceException { content = root; contentType = OM; QName qName = root.getQName(); if (protocol == null) { if (qName.getNamespaceURI().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { this.protocol = Protocol.soap11; } else if (qName.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { this.protocol = Protocol.soap12; } } else if (protocol == Protocol.rest) { this.protocol = Protocol.rest; // Axis2 stores XML/HTTP messages inside a soap11 envelope. We will mimic this behavior if (qName.getNamespaceURI().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { // Okay } else if (qName.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) { // throw ExceptionFactory. // makeWebServiceException(Messages.getMessage("restWithSOAPErr")); // Okey } else { content = _createSpine(Protocol.rest, Style.DOCUMENT, 0, root); contentType = SPINE; } } else { this.protocol = protocol; } }
public void setStyle(Style style) throws WebServiceException { if (this.style != style) { if (contentType == SPINE) { // Must switch to something other than XMLSpine getContentAsOMElement(); } } this.style = style; if (style == Style.RPC) { setIndirection(1); } else { setIndirection(0); } }
public @Nullable QName getReqPayloadName() { if (emptyRequestPayload) return null; if (requestPayloadName != null) return requestPayloadName; if(style.equals(Style.RPC)){ String ns = getRequestNamespace() != null ? getRequestNamespace() : name.getNamespaceURI(); requestPayloadName = new QName(ns, name.getLocalPart()); return requestPayloadName; }else{ QName inMsgName = operation.getInput().getMessage().getName(); WSDLMessageImpl message = messages.get(inMsgName); for(WSDLPartImpl part:message.parts()){ ParameterBinding binding = getInputBinding(part.getName()); if(binding.isBody()){ requestPayloadName = part.getDescriptor().name(); return requestPayloadName; } } //Its empty payload emptyRequestPayload = true; } //empty body return null; }
public @Nullable QName getResPayloadName() { if (emptyResponsePayload) return null; if (responsePayloadName != null) return responsePayloadName; if(style.equals(Style.RPC)){ String ns = getResponseNamespace() != null ? getResponseNamespace() : name.getNamespaceURI(); responsePayloadName = new QName(ns, name.getLocalPart()+"Response"); return responsePayloadName; }else{ QName outMsgName = operation.getOutput().getMessage().getName(); WSDLMessageImpl message = messages.get(outMsgName); for(WSDLPartImpl part:message.parts()){ ParameterBinding binding = getOutputBinding(part.getName()); if(binding.isBody()){ responsePayloadName = part.getDescriptor().name(); return responsePayloadName; } } //Its empty payload emptyResponsePayload = true; } //empty body return null; }
/** * Get {@link Style} - such as <code>document</code> or <code>rpc</code>. */ public Style getStyle() { return style; }
/** * Returns true if its document/literal */ public boolean isDocLit() { return style == Style.DOCUMENT && use == Use.LITERAL; }
/** * Returns true if this is a rpc/literal binding */ public boolean isRpcLit() { return style == Style.RPC && use == Use.LITERAL; }
void processClass(Class clazz) { classUsesWebMethod = new HashSet<Class>(); determineWebMethodUse(clazz); WebService webService = getAnnotation(clazz, WebService.class); QName portTypeName = getPortTypeName(clazz, targetNamespace, metadataReader); // String portTypeLocalName = clazz.getSimpleName(); // if (webService.name().length() >0) // portTypeLocalName = webService.name(); // // targetNamespace = webService.targetNamespace(); packageName = ""; if (clazz.getPackage() != null) packageName = clazz.getPackage().getName(); // if (targetNamespace.length() == 0) { // targetNamespace = getNamespace(packageName); // } // model.setTargetNamespace(targetNamespace); // QName portTypeName = new QName(targetNamespace, portTypeLocalName); targetNamespace = portTypeName.getNamespaceURI(); model.setPortTypeName(portTypeName); model.setTargetNamespace(targetNamespace); model.defaultSchemaNamespaceSuffix = config.getMappingInfo().getDefaultSchemaNamespaceSuffix(); model.setWSDLLocation(webService.wsdlLocation()); SOAPBinding soapBinding = getAnnotation(clazz, SOAPBinding.class); if (soapBinding != null) { if (soapBinding.style() == SOAPBinding.Style.RPC && soapBinding.parameterStyle() == SOAPBinding.ParameterStyle.BARE) { throw new RuntimeModelerException("runtime.modeler.invalid.soapbinding.parameterstyle", soapBinding, clazz); } isWrapped = soapBinding.parameterStyle()== WRAPPED; } defaultBinding = createBinding(soapBinding); /* * if clazz != portClass then there is an SEI. If there is an * SEI, then all methods should be processed. However, if there is * no SEI, and the implementation class uses at least one * WebMethod annotation, then only methods with this annotation * will be processed. */ /* if (clazz == portClass) { WebMethod webMethod; for (Method method : clazz.getMethods()) { webMethod = getPrivMethodAnnotation(method, WebMethod.class); if (webMethod != null && !webMethod.exclude()) { usesWebMethod = true; break; } } }*/ for (Method method : clazz.getMethods()) { if (!clazz.isInterface()) { // if clazz is SEI, then all methods are web methods if (method.getDeclaringClass() == Object.class) continue; if (!getBooleanSystemProperty("com.sun.xml.internal.ws.legacyWebMethod")) { // legacy webMethod computation behaviour to be used if (!isWebMethodBySpec(method, clazz)) continue; } else { if (!isWebMethod(method)) continue; } } // TODO: binding can be null. We need to figure out how to post-process // RuntimeModel to link to WSDLModel processMethod(method); } //Add additional jaxb classes referenced by {@link XmlSeeAlso} XmlSeeAlso xmlSeeAlso = getAnnotation(clazz, XmlSeeAlso.class); if(xmlSeeAlso != null) model.addAdditionalClasses(xmlSeeAlso.value()); }
/** * @param style The style to set. */ public void setStyle(Style style) { this.style = style; }
public void setStyle(Style style){ this.style = style; }
public SOAPBinding.Style getStyle() { return style; }
public boolean isRpcLit(){ return Style.RPC==style; }
public boolean isDoclit(){ return Style.DOCUMENT==style; }
private void parseBindingOperation(XMLStreamReader reader, EditableWSDLBoundPortType binding) { String bindingOpName = ParserUtil.getMandatoryNonEmptyAttribute(reader, "name"); if (bindingOpName == null) { //TODO: throw exception? //skip wsdl:binding element for now XMLStreamReaderUtil.skipElement(reader); return; } QName opName = new QName(binding.getPortTypeName().getNamespaceURI(), bindingOpName); EditableWSDLBoundOperation bindingOp = new WSDLBoundOperationImpl(reader,binding, opName); binding.put(opName, bindingOp); extensionFacade.bindingOperationAttributes(bindingOp, reader); while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) { QName name = reader.getName(); String style = null; if (WSDLConstants.QNAME_INPUT.equals(name)) { parseInputBinding(reader, bindingOp); } else if (WSDLConstants.QNAME_OUTPUT.equals(name)) { parseOutputBinding(reader, bindingOp); } else if (WSDLConstants.QNAME_FAULT.equals(name)) { parseFaultBinding(reader, bindingOp); } else if (SOAPConstants.QNAME_OPERATION.equals(name) || SOAPConstants.QNAME_SOAP12OPERATION.equals(name)) { style = reader.getAttributeValue(null, "style"); String soapAction = reader.getAttributeValue(null, "soapAction"); if (soapAction != null) bindingOp.setSoapAction(soapAction); goToEnd(reader); } else { extensionFacade.bindingOperationElements(bindingOp, reader); } /** * If style attribute is present set it otherwise set the style as defined * on the <soap:binding> element */ if (style != null) { if (style.equals("rpc")) bindingOp.setStyle(Style.RPC); else bindingOp.setStyle(Style.DOCUMENT); } else { bindingOp.setStyle(binding.getStyle()); } } }