• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SOAPFaultValue类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.apache.axiom.soap.SOAPFaultValue的典型用法代码示例。如果您正苦于以下问题:Java SOAPFaultValue类的具体用法?Java SOAPFaultValue怎么用?Java SOAPFaultValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

SOAPFaultValue类属于org.apache.axiom.soap包,在下文中一共展示了SOAPFaultValue类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createTfsExceptionFromAxisFault

点赞 2

import org.apache.axiom.soap.SOAPFaultValue; //导入依赖的package包/类
@Nullable
private static TfsException createTfsExceptionFromAxisFault(AxisFault axisFault) {
  TfsException result = createTfsExceptionFromThrowable(axisFault.getCause());
  if (result != null) {
    return result;
  }

  SOAPFaultCode code = axisFault.getFaultCodeElement();
  if (code != null) {
    SOAPFaultSubCode subCode = code.getSubCode();
    if (subCode != null) {
      SOAPFaultValue subcodeValue = subCode.getValue();
      if (subcodeValue != null) {
        String subcodeText = subcodeValue.getText();
        if (subcodeText != null) {
          Class<?> exceptionClass = ourExceptionsBySubcodes.get(subcodeText);
          if (exceptionClass != null) {
            try {
              return (TfsException)exceptionClass.getConstructor(AxisFault.class).newInstance(axisFault);
            }
            catch (Exception e) {
              // skip
            }
          }
        }
      }
    }
  }

  int errorCode = getTransportErrorCode(axisFault);
  if (errorCode != -1) {
    return createHttpTransportErrorException(errorCode, axisFault);
  }
  return new UnknownException(axisFault);
}
 

开发者ID:Microsoft,
项目名称:vso-intellij,
代码行数:36,
代码来源:TfsExceptionManager.java

示例2: testFaultSerialization

点赞 2

import org.apache.axiom.soap.SOAPFaultValue; //导入依赖的package包/类
public void testFaultSerialization() throws Exception {
    final String REASON = "ReasonValue";

    SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
    SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode();
    SOAPFaultValue soapFaultValue = soapFactory
            .createSOAPFaultValue(soapFaultCode);
    soapFaultValue.setText(new QName(
            SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, "Sender"));

    SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason();
    SOAPFaultText soapFaultText = soapFactory
            .createSOAPFaultText(soapFaultReason);
    soapFaultText.setText(REASON);

    SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail();
    QName qName = new QName("http://mycompany.com", "FaultException", "ex");
    OMElement exception = soapFactory.createOMElement(qName,
            soapFaultDetail);
    exception.setText("Detail text");
    AxisFault fault = new AxisFault(soapFaultCode, soapFaultReason, null,
            null, soapFaultDetail);

    ConfigurationContext cc = ConfigurationContextFactory
            .createDefaultConfigurationContext();
    MessageContext ctx = cc.createMessageContext();
    SOAPFactory fac = OMAbstractFactory.getSOAP12Factory();
    ctx.setEnvelope(fac.getDefaultEnvelope());
    MessageContext faultCtx = MessageContextBuilder
            .createFaultMessageContext(ctx, fault);

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    TransportUtils.writeMessage(faultCtx, bos);

    String result = new String(bos.toByteArray());

    // For right now, just making sure we have a test for AXIS2-2752
    // Confirm reason was correctly processed
    assertTrue("Incorrect or missing reason!", result.indexOf(REASON) > -1);
}
 

开发者ID:wso2,
项目名称:wso2-axis2,
代码行数:41,
代码来源:FaultSerializationTest.java

示例3: initFaultInformation

点赞 2

import org.apache.axiom.soap.SOAPFaultValue; //导入依赖的package包/类
private void initFaultInformation(MessageContext inMessageContext) {
    SOAPFactory soapFactory;
    if (inMessageContext.isSOAP11()) {
        soapFactory = OMAbstractFactory.getSOAP11Factory();
    } else {
        soapFactory = OMAbstractFactory.getSOAP12Factory();
    }

    soapFaultCode = soapFactory.createSOAPFaultCode();
    SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
    soapFaultValue.setText(new QName("http://test.org", "TestFault", "test"));

    soapFaultReason = soapFactory.createSOAPFaultReason();
    SOAPFaultText soapFaultText = soapFactory.createSOAPFaultText(soapFaultReason);
    soapFaultText.setText("This is some FaultReason");

    soapFaultDetail = soapFactory.createSOAPFaultDetail();
    QName qName = new QName("http://someuri.org", "FaultException");
    OMElement detail = soapFactory.createOMElement(qName, soapFaultDetail);
    qName = new QName("http://someuri.org", "ExceptionMessage");
    Throwable e = new Exception("This is a test Exception");
    while (e != null) {
        OMElement exception = soapFactory.createOMElement(qName, null);
        exception.setText(e.getMessage());
        detail.addChild(exception);
        e = e.getCause();
    }
}
 

开发者ID:wso2,
项目名称:wso2-axis2,
代码行数:29,
代码来源:FaultThrowingService.java

示例4: setFaultCode

点赞 2

import org.apache.axiom.soap.SOAPFaultValue; //导入依赖的package包/类
/**
     * Sets this <CODE>SOAPFault</CODE> object with the given fault code.
     * <p/>
     * Fault codes, which given information about the fault, are defined in the SOAP 1.1
     * specification. This element is mandatory in SOAP 1.1. Because the fault code is required to
     * be a QName it is preferable to use the setFaultCode(Name)form of this method.
     *
     * @param faultCode - a String giving the fault code to be set. It must be of the form
     *                  "prefix:localName" where the prefix has been defined in a namespace
     *                  declaration.
     * @throws SOAPException - if there was an error in adding the faultCode to the underlying XML
     *                       tree.
     * @see setFaultCode(Name), getFaultCode(),SOAPElement.addNamespaceDeclaration(String, String)
     */
    public void setFaultCode(String faultCode) throws SOAPException {
        org.apache.axiom.soap.SOAPFactory soapFactory = null;
        SOAPFaultCode soapFaultCode = null;

        //It must be of the form "prefix:localName" where the prefix has been defined in a
        //namespace declaration.
        if (faultCode.indexOf(":") == -1) {
            throw new SOAPException("faultCode must be of the form prefix:localName");
        }
//        	else{
//            	String prefix,localName ="";
//        		prefix = faultCode.substring(0, faultCode.indexOf(":"));
//        		localName = faultCode.substring(faultCode.indexOf(":")+1);
//        	}

        if (this.element.getOMFactory() instanceof SOAP11Factory) {
            soapFactory = (SOAP11Factory)this.element.getOMFactory();
            soapFaultCode = soapFactory.createSOAPFaultCode(fault);
            soapFaultCode.setText(faultCode);
        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
            soapFactory = (SOAP12Factory)this.element.getOMFactory();
            soapFaultCode = soapFactory.createSOAPFaultCode(fault);
            SOAPFaultValue soapFaultValue = soapFactory.createSOAPFaultValue(soapFaultCode);
            soapFaultCode.setValue(soapFaultValue);
            soapFaultValue.setText(faultCode);
        }

        this.fault.setCode(soapFaultCode);
    }
 

开发者ID:wso2,
项目名称:wso2-axis2,
代码行数:44,
代码来源:SOAPFaultImpl.java

示例5: invoke

点赞 2

import org.apache.axiom.soap.SOAPFaultValue; //导入依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
    // this handler will be used to check the fault handling of Axis2.
    // this will create some dummy faults and send

    SOAPFactory soapFac = msgContext.isSOAP11() ? OMAbstractFactory.getSOAP11Factory() :
            OMAbstractFactory.getSOAP12Factory();

    // I have a sudden fake error ;)
    OMElement firstElement = msgContext.getEnvelope().getBody().getFirstElement();

    OMElement detailEntry = soapFac.createOMElement("MoreInfo", null);
    detailEntry.setText(DETAIL_MORE_INFO);

    if (ERR_HANDLING_WITH_MSG_CTXT.equals(firstElement.getLocalName())) {
        SOAPFaultCode soapFaultCode = soapFac.createSOAPFaultCode();
        soapFaultCode.declareNamespace("http://someuri.org", "m");
        if (msgContext.isSOAP11()) {
            soapFaultCode.setText(M_FAULT_EXCEPTION);
        } else {
            SOAPFaultValue soapFaultValue = soapFac.createSOAPFaultValue(soapFaultCode);
            soapFaultValue.setText(M_FAULT_EXCEPTION);
        }

        SOAPFaultReason soapFaultReason = soapFac.createSOAPFaultReason();

        if (msgContext.isSOAP11()) {
            soapFaultReason.setText(FAULT_REASON);
        } else {
            SOAPFaultText soapFaultText = soapFac.createSOAPFaultText();
            soapFaultText.setLang("en");
            soapFaultText.setText(FAULT_REASON);
            soapFaultReason.addSOAPText(soapFaultText);
        }

        SOAPFaultDetail faultDetail = soapFac.createSOAPFaultDetail();
        faultDetail.addDetailEntry(detailEntry);

        msgContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME, soapFaultCode);
        msgContext.setProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME, soapFaultReason);
        msgContext.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, faultDetail);

        throw new AxisFault("A dummy exception has occurred");
    } else if (ERR_HANDLING_WITH_AXIS_FAULT.equals(firstElement.getLocalName())) {
        throw new AxisFault(new QName(M_FAULT_EXCEPTION), FAULT_REASON, null, null,
                            detailEntry);
    }
    return InvocationResponse.CONTINUE;
}
 

开发者ID:wso2,
项目名称:wso2-axis2,
代码行数:49,
代码来源:FaultHandler.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)