當前位置: 首頁>>代碼示例>>Java>>正文


Java SOAPFault.appendFaultSubcode方法代碼示例

本文整理匯總了Java中javax.xml.soap.SOAPFault.appendFaultSubcode方法的典型用法代碼示例。如果您正苦於以下問題:Java SOAPFault.appendFaultSubcode方法的具體用法?Java SOAPFault.appendFaultSubcode怎麽用?Java SOAPFault.appendFaultSubcode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.soap.SOAPFault的用法示例。


在下文中一共展示了SOAPFault.appendFaultSubcode方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: throwSoapFaultException

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void throwSoapFaultException()
{
   try
   {
      MessageContext ctx = context.getMessageContext();
      ctx.put(MessageContext.HTTP_RESPONSE_CODE, 400);
      
      SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
      SOAPFault fault = factory.createFault();
      fault.addFaultReasonText("this is a fault string!", Locale.ITALIAN);
      fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
      fault.setFaultActor("mr.actor");
      fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "AnException"));
      fault.addDetail().addChildElement("test");
      throw new SOAPFaultException(fault);
   }
   catch (Exception s)
   {
      throw new RuntimeException(s);
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:22,代碼來源:JBWS3945EndpointImpl.java

示例2: throwSoapFaultException

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void throwSoapFaultException()
{
   // This should be thrown as-is
   try
   {
      SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
      SOAPFault fault = factory.createFault();
      fault.addFaultReasonText("this is a fault string!", Locale.ITALIAN);
      fault.setFaultCode(SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
      fault.setFaultActor("mr.actor");
      fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "NullPointerException"));
      fault.addDetail().addChildElement("test");
      throw new SOAPFaultException(fault);
   }
   catch (SOAPException s)
   {
      throw new RuntimeException(s);
   }
}
 
開發者ID:jbossws,項目名稱:jbossws-cxf,代碼行數:20,代碼來源:SOAP12EndpointImpl.java

示例3: testAppendSubCode

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testAppendSubCode() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault soapFault = body.addFault();
    QName qname = new QName("http://example.com", "myfault1", "flt1");
    soapFault.appendFaultSubcode(qname);

    QName qname2 = new QName("http://example2.com", "myfault2", "flt2");
    soapFault.appendFaultSubcode(qname2);

    QName qname3 = new QName("http://example3.com", "myfault3", "flt3");
    soapFault.appendFaultSubcode(qname3);

    soapMessage.saveChanges();

    Iterator faultSubCodes = soapFault.getFaultSubcodes();
    assertNotNull(faultSubCodes);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:24,代碼來源:SOAPFaultTest.java

示例4: createInvalidAddressingHeaderFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
    QName name = e.getProblemHeader();
    QName subsubcode = e.getSubsubcode();
    QName subcode = av.invalidMapTag;
    String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getInvalidMapDetail(name, fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:WsaTubeHelper.java

示例5: newMapRequiredFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
    QName subcode = addVer.mapRequiredTag;
    QName subsubcode = addVer.mapRequiredTag;
    String faultstring = addVer.getMapRequiredText();

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.getSOAPFactory();
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:WsaTubeHelper.java

示例6: fillFaultSubCodes

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
/**
 * Recursively populate the Subcodes
 */
private void fillFaultSubCodes(SOAPFault fault, SubcodeType subcode) throws SOAPException {
    if(subcode != null){
        fault.appendFaultSubcode(subcode.getValue());
        fillFaultSubCodes(fault, subcode.getSubcode());
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:SOAP12Fault.java

示例7: createInvalidAddressingHeaderFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public SOAPFault createInvalidAddressingHeaderFault(InvalidAddressingHeaderException e, AddressingVersion av) {
    QName name = e.getProblemHeader();
    QName subsubcode = e.getSubsubcode();
    QName subcode = av.invalidMapTag;
    String faultstring = String.format(av.getInvalidMapText(), name, subsubcode);

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.saajSoapFactory;
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getInvalidMapDetail(name, fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.saajSoapFactory;
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
開發者ID:alexkasko,項目名稱:openjdk-icedtea7,代碼行數:30,代碼來源:WsaTubeHelper.java

示例8: newMapRequiredFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public SOAPFault newMapRequiredFault(MissingAddressingHeaderException e) {
    QName subcode = addVer.mapRequiredTag;
    QName subsubcode = addVer.mapRequiredTag;
    String faultstring = addVer.getMapRequiredText();

    try {
        SOAPFactory factory;
        SOAPFault fault;
        if (soapVer == SOAPVersion.SOAP_12) {
            factory = SOAPVersion.SOAP_12.saajSoapFactory;
            fault = factory.createFault();
            fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            fault.appendFaultSubcode(subcode);
            fault.appendFaultSubcode(subsubcode);
            getMapRequiredDetail(e.getMissingHeaderQName(), fault.addDetail());
        } else {
            factory = SOAPVersion.SOAP_11.saajSoapFactory;
            fault = factory.createFault();
            fault.setFaultCode(subsubcode);
        }

        fault.setFaultString(faultstring);

        return fault;
    } catch (SOAPException se) {
        throw new WebServiceException(se);
    }
}
 
開發者ID:alexkasko,項目名稱:openjdk-icedtea7,代碼行數:29,代碼來源:WsaTubeHelper.java

示例9: createSOAPFaultException

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
private SOAPFaultException createSOAPFaultException(String code, String reason) {
  LOGGER.info("SOAP Fault: " + reason);
  try {
    SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPFault fault = factory.createFault(reason, SOAPConstants.SOAP_RECEIVER_FAULT);
    fault.appendFaultSubcode(new QName(NS_SAMPLES, code + 1));
    fault.appendFaultSubcode(new QName(NS_SAMPLES, code + 2));
    fault.appendFaultSubcode(new QName(NS_SAMPLES, code + 3));
    fault.addDetail().addChildElement("message").setTextContent(reason);
    return new SOAPFaultException(fault);
  } catch (SOAPException e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
}
 
開發者ID:tadayosi,項目名稱:samples-jbossws,代碼行數:16,代碼來源:GreetingService.java

示例10: testAppendFaultSubCode

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testAppendFaultSubCode() throws Exception {
    MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage soapMessage = fac.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("cwmp", "http://cwmp.com");
    SOAPBody body = envelope.getBody();
    SOAPFault sf = body.addFault();

    QName expected1 = new QName("http://example.com", "myfault1", "flt1");
    QName expected2 = new QName("http://example.com", "myfault2", "flt2");
    boolean found1 = false;
    boolean found2 = false;

    //Appending fault Subcode
    sf.appendFaultSubcode(expected1);
    //Appending a second fault Subcode
    sf.appendFaultSubcode(expected2);

    //Getting FaultSubCodes from SOAPFault
    Iterator i = sf.getFaultSubcodes();
    int j = 0;
    while (i.hasNext()) {
        Object o = i.next();
        if (o != null && o instanceof QName) {
            QName actual = (QName)o;
            if (actual.equals(expected1)) {
                if (!found1) {
                    found1 = true;
                    //System.out.println("Subcode= '"+actual+"'");
                } else {
                    //System.out.println("Received a duplicate Subcode :'"+actual+"'");
                }
            } else if (actual.equals(expected2)) {
                if (!found2) {
                    found2 = true;
                    //System.out.println("Subcode= '"+actual+"'");
                } else {
                    //System.out.println("Received a duplicate Subcode :'"+actual+"'");
                }
            }
        }
        j++;
    }
    if (j < 1) {
        fail("No Subcode was returned");
    }
    if (j > 2) {
        fail("More than two Subcodes were returned");
    }
    if (!found1) {
        fail("The following Subcode was not received: '" + expected1 + "'");
    }
    if (!found2) {
        fail("The following Subcode was not received: '" + expected2 + "'");
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:59,代碼來源:SOAPFaultTest.java


注:本文中的javax.xml.soap.SOAPFault.appendFaultSubcode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。