javax.wsdl.Message类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.7k)|赞(0)|评价(0)|浏览(216)

本文整理了Java中javax.wsdl.Message类的一些代码示例,展示了Message类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message类的具体详情如下:
包路径:javax.wsdl.Message
类名称:Message

Message介绍

[英]This interface describes a message used for communication with an operation.
[中]此接口描述用于与操作通信的消息。

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

/**
  * Create a WsdlOpFault from the Fault.
  *
  * @param fault
  *          Fault to process.
  * @return WsdlOpFault Result of processing.
  */
 @SuppressWarnings( "unchecked" )
 private WsdlOpFault getFault( Fault fault ) throws KettleStepException {
  Message m = fault.getMessage();

  // a fault should only have one message part.
  Map<?, Part> partMap = m.getParts();
  if ( partMap.size() != 1 ) {
   throw new IllegalArgumentException( "Invalid part count for fault!!" );
  }
  Part faultPart = partMap.values().iterator().next();
  boolean complexType = false;

  // type of fault is specified either in Part's type or element attribute.
  QName type = faultPart.getTypeName();
  if ( type == null ) {
   type = faultPart.getElementName();
   Element schemaElement = _wsdlTypes.findNamedElement( type );
   type = _wsdlTypes.getTypeQName( schemaElement.getAttribute( "type" ) );
   complexType = true;
  }
  return new WsdlOpFault( fault.getName(), type, complexType, _wsdlTypes );
 }
}

代码示例来源:origin: wsdl4j/wsdl4j

if (!message.isUndefined())
 QName name = message.getQName();
              name.getLocalPart(),
              pw);
 printDocumentation(message.getDocumentationElement(), def, pw);
 printParts(message.getOrderedParts(null), def, pw);
 List extElements = message.getExtensibilityElements();

代码示例来源:origin: wsdl4j/wsdl4j

QName messageName = new QName(def.getTargetNamespace(), name);
 msg = def.getMessage(messageName);
  msg = def.createMessage();
  msg.setQName(messageName);
msg.setUndefined(false);
  msg.setDocumentationElement(tempEl);
  msg.addPart(parsePart(tempEl, def));
  msg.addExtensibilityElement(
   parseExtensibilityElement(Message.class, tempEl, def));

代码示例来源:origin: org.apache.ode/ode-jbi

private Message copyMessage(Message defMessage, Definition flat) {
  Message flatMsg = flat.createMessage();
  flatMsg.setUndefined(false);
  if (defMessage.getQName() != null) {
    flatMsg.setQName(new QName(flat.getTargetNamespace(), defMessage.getQName().getLocalPart()));
  }
  for (Iterator itPart = defMessage.getParts().values().iterator(); itPart.hasNext();) {
    Part defPart = (Part) itPart.next();
    Part flatPart = flat.createPart();
    flatPart.setName(defPart.getName());
    flatPart.setElementName(defPart.getElementName());
    flatMsg.addPart(flatPart);
  }
  return flatMsg;
}

代码示例来源:origin: org.n52.amused/amused-core

public static QName getInputPartName(Operation op)
{
  Input input = op.getInput();
  Map parts = input.getMessage().getParts();
  //
  // one message, one part, one XSD element - that's the system
  //
  if (parts.size() != 1)
  {
    Object[] filler = { op.getName() };
    throw new RuntimeException(_MESSAGES.get("NotDocLiteral", filler));
  }
  Part docLiteralPart = (Part)parts.values().iterator().next();
  QName partName = docLiteralPart.getElementName();
  //
  // HACK: this is for Axis/Axiom - they don't handle the default
  // namespace/prefix well, so we always use a prefix
  //
  String prefix = partName.getPrefix();
  if (prefix == null || prefix.length() == 0)
    partName = new QName(partName.getNamespaceURI(), partName.getLocalPart(), "muse-op");
  return partName;
}

代码示例来源:origin: apache/cxf

private void createFaultMessage(QName qname) {
  String exceptionName = qname.getLocalPart();
  // messages
  Message faultMsg = definition.createMessage();
  faultMsg.setQName(new QName(definition.getTargetNamespace(), exceptionName));
  faultMsg.setUndefined(false);
  // message - part
  Part part = definition.createPart();
  part.setName("exception");
  part.setElementName(qname);
  faultMsg.addPart(part);
  //add the fault element namespace to the definition
  String nsURI = qname.getNamespaceURI();
  manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(nsURI), nsURI);
  definition.addMessage(faultMsg);
}

代码示例来源:origin: apache/cxf

BindingOperation bindingOperation,
              QName elementQName) {
String exceptionName = corbaType.getQName().getLocalPart();
Definition faultDef = manager.getWSDLDefinition(elementQName.getNamespaceURI());
if (faultDef == null) {
  faultDef = definition;
Message faultMsg = faultDef.getMessage(new QName(faultDef.getTargetNamespace(), exceptionName));
if (faultMsg == null) {
  throw new RuntimeException("Fault message for exception " + exceptionName + " not found");
Fault fault = definition.createFault();
fault.setMessage(faultMsg);
fault.setName(faultMsg.getQName().getLocalPart());
operation.addFault(fault);
BindingFault bindingFault = definition.createBindingFault();
bindingFault.setName(faultMsg.getQName().getLocalPart());
bindingOperation.addBindingFault(bindingFault);

代码示例来源:origin: org.codehaus.xfire/xfire-core

protected void visit(Input input)
{
  if (isWrapped)
  {
    Part part = (Part) input.getMessage().getParts().values().iterator().next();
    MessageInfo info = opInfo.createMessage(new QName(part.getElementName().getNamespaceURI(),
                             input.getMessage().getQName().getLocalPart()));
    winput2msg.put(input, info);
    
    opInfo.setInputMessage(info);
    
    createMessageParts(info, getWrappedSchema(input.getMessage()));
  }
  else
  {
    MessageInfo info = opInfo.createMessage(input.getMessage().getQName());
    winput2msg.put(input, info);
    
    opInfo.setInputMessage(info);
    createMessageParts(info,  input.getMessage());
  }
}

代码示例来源:origin: org.apache.cxf/cxf-common-utilities

public Map getParts(Operation operation, boolean out) {
  Message message = null;
  if (out) {
    Output output = operation.getOutput();
    message = output.getMessage();
  } else {
    Input input = operation.getInput();
    message = input.getMessage();
  }
  return message.getParts() == null ? new HashMap() : message.getParts();
}

代码示例来源:origin: org.wso2.carbon.business-process/org.wso2.carbon.bpel

private static String findHeaderPartName(List<javax.wsdl.extensions.soap.SOAPHeader> headerDefs,
                     Definition wsdl,
                     QName elmtName) {
  for (javax.wsdl.extensions.soap.SOAPHeader headerDef : headerDefs) {
    Message hdrMsg = wsdl.getMessage(headerDef.getMessage());
    for (Object o : hdrMsg.getParts().values()) {
      Part p = (Part) o;
      if (p.getElementName().equals(elmtName)) {
        return p.getName();
      }
    }
  }
  return elmtName.getLocalPart();
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

protected Message createHeaderMessages(WSDLBuilder builder, MessageInfo msgInfo, List headers)
{
  Message msg = builder.getDefinition().createMessage();
  msg.setQName(new QName(builder.getTargetNamespace(), 
              msgInfo.getName().getLocalPart() + "Headers"));
  msg.setUndefined(false);
  for (Iterator itr = headers.iterator(); itr.hasNext();)
  {
    MessagePartInfo header = (MessagePartInfo) itr.next();
    Part part = builder.createPart(header);
    msg.addPart(part);
  }
  return msg;
}

代码示例来源:origin: org.springframework.ws/spring-ws-core

/**
 * Called after the {@link javax.wsdl.Input} has been created, but it's added to the operation. Subclasses can
 * override this method to define the input name.
 *
 * <p>Default implementation sets the input name to the message name.
 *
 * @param definition the WSDL4J {@code Definition}
 * @param input         the WSDL4J {@code Input}
 */
protected void populateInput(Definition definition, Input input) {
  input.setName(input.getMessage().getQName().getLocalPart());
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

private Fault createFault(OperationInfo op, FaultInfo faultInfo)
{
  Message faultMsg = getDefinition().createMessage();
  faultMsg.setQName(new QName(getTargetNamespace(), faultInfo.getName()));
  faultMsg.setUndefined(false);
  getDefinition().addMessage(faultMsg);
  Fault fault = getDefinition().createFault();
  fault.setName(faultInfo.getName());
  fault.setMessage(faultMsg);
  for (Iterator itr = faultInfo.getMessageParts().iterator(); itr.hasNext();)
  {
    MessagePartInfo info = (MessagePartInfo) itr.next();
    String uri = info.getName().getNamespaceURI();
    addNamespace(getNamespacePrefix(uri), uri);
    Part part = createPart(info);
    faultMsg.addPart(part);
  }
  return fault;
}

代码示例来源:origin: apache/cxf

protected void buildMessage(Message message,
              AbstractMessageContainer messageContainer,
              final Definition def) {
  addDocumentation(message, messageContainer.getMessageDocumentation());
  message.setQName(messageContainer.getName());
  message.setUndefined(false);
  def.addMessage(message);
  List<MessagePartInfo> messageParts = messageContainer.getMessageParts();
  Part messagePart = null;
  for (MessagePartInfo messagePartInfo : messageParts) {
    messagePart = def.createPart();
    messagePart.setName(messagePartInfo.getName().getLocalPart());
    if (messagePartInfo.isElement()) {
      messagePart.setElementName(messagePartInfo.getElementQName());
      addNamespace(messagePartInfo.getElementQName().getNamespaceURI(), def);
    } else if (messagePartInfo.getTypeQName() != null) {
      messagePart.setTypeName(messagePartInfo.getTypeQName());
      addNamespace(messagePartInfo.getTypeQName().getNamespaceURI(), def);
    }
    message.addPart(messagePart);
  }
}

代码示例来源:origin: org.objectweb.jonas/jonas-deployment

/**
 * return true if shQName is defined in WSDL services.
 * @param shQName a soap header Qname that could be defined in the WSDL.
 * @return true if SOAP Header has been found in WSDL Definition.
 */
public boolean hasSOAPHeader(QName shQName) {
  Map msgs = def.getMessages();
  for (Iterator m = msgs.values().iterator(); m.hasNext();) {
    Message msg = (Message) m.next();
    if (msg.getQName().getNamespaceURI() == shQName.getNamespaceURI()) {
      Part p = msg.getPart(shQName.getLocalPart());
      if (p != null) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: jboss-switchyard/components

/**
 * Get the SOAP {@link Operation} instance for the specified message element.
 *
 * @param port The WSDL port.
 * @param elementName The SOAP Body element QName.
 * @param documentStyle true if it is 'document', false if 'rpc'.
 * @return The Operation instance, or null if the operation was not found on the port.
 */
public static Operation getOperationByElement(Port port, QName elementName, Boolean documentStyle) {
  List<Operation> operations = port.getBinding().getPortType().getOperations();
  for (Operation operation : operations) {
    if (!documentStyle && (elementName.getLocalPart().equals(operation.getName()))) {
      return operation;
    } else {
      // Note: WS-I Profile allows only one child under SOAPBody.
      Part part = (Part)operation.getInput().getMessage().getParts().values().iterator().next();
      if ((part.getElementName() != null) && elementName.equals(part.getElementName())
        || (part.getTypeName() != null) && elementName.equals(part.getTypeName())) {
        return operation;
      } else if (elementName.getLocalPart().equals(operation.getName())) {
        return operation;
      }
    }
  }
  return null;
}

代码示例来源:origin: apache/cxf

private XNode getXNode(javax.wsdl.Message msg) {
  XDef xdef = new XDef();
  xdef.setTargetNamespace(msg.getQName().getNamespaceURI());
  XMessage mNode = new XMessage();
  mNode.setName(msg.getQName().getLocalPart());
  mNode.setParentNode(xdef);
  return mNode;
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

private Message createOutputMessage(OperationInfo op)
{
  // response message
  Message res = getDefinition().createMessage();
  res.setQName(new QName(getTargetNamespace(), op.getName() + "Response"));
  res.setUndefined(false);
  if (getService().getServiceInfo().isWrapped())
    createWrappedOutputParts(res, op);
  else
    createOutputParts(res, op);
  return res;
}

代码示例来源:origin: apache/cxf

private Operation generateOperation(String name, Message inputMsg, Message outputMsg) {
  Input input = definition.createInput();
  input.setName(inputMsg.getQName().getLocalPart());
  input.setMessage(inputMsg);
  Output output = definition.createOutput();
  output.setName(outputMsg.getQName().getLocalPart());
  output.setMessage(outputMsg);
  Operation result = definition.createOperation();
  result.setName(name);
  result.setInput(input);
  result.setOutput(output);
  result.setUndefined(false);
  portType.addOperation(result);
  return result;
}

代码示例来源:origin: apache/cxf

public Message generateInputMessage(Operation operation, BindingOperation bindingOperation) {
  Message msg = definition.createMessage();
  QName msgName;
  if (!mapper.isDefaultMapping()) {
    //mangle the message name
    //REVISIT, do we put in the entire scope for mangling
    msgName = new QName(definition.getTargetNamespace(),
              getScope().tail() + "." + operation.getName());
  } else {
    msgName = new QName(definition.getTargetNamespace(), operation.getName());
  }
  msg.setQName(msgName);
  msg.setUndefined(false);
  String inputName = operation.getName() + REQUEST_SUFFIX;
  Input input = definition.createInput();
  input.setName(inputName);
  input.setMessage(msg);
  BindingInput bindingInput = definition.createBindingInput();
  bindingInput.setName(inputName);
  bindingOperation.setBindingInput(bindingInput);
  operation.setInput(input);
  definition.addMessage(msg);
  return msg;
}

相关文章