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


Java SOAPFault.getFaultCodeAsQName方法代碼示例

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


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

示例1: SOAP12Fault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
SOAP12Fault(SOAPFault fault) {
    code = new CodeType(fault.getFaultCodeAsQName());
    try {
        fillFaultSubCodes(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }

    reason = new ReasonType(fault.getFaultString());
    role = fault.getFaultRole();
    node = fault.getFaultNode();
    if (fault.getDetail() != null) {
        detail = new DetailType();
        Iterator iter = fault.getDetail().getDetailEntries();
        while(iter.hasNext()){
            Element fd = (Element)iter.next();
            detail.getDetails().add(fd);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:SOAP12Fault.java

示例2: testCreateFault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testCreateFault() {
    try {
        SOAPFactory factory = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        //SOAPFactory factory = SOAPFactory.newInstance();
        SOAPFault sf = factory.createFault("This is the fault reason.",
                                           SOAPConstants.SOAP_RECEIVER_FAULT);
        assertNotNull(sf);
        assertTrue(sf instanceof SOAPFault);
        QName fc = sf.getFaultCodeAsQName();
        //Expect FaultCode="+SOAPConstants.SOAP_RECEIVER_FAULT
        Iterator i = sf.getFaultReasonTexts();
        if (i == null) {
            log.info("Call to getFaultReasonTexts() returned null iterator");
        }
        String reason = "";
        while (i.hasNext()) {
            reason += (String)i.next();
        }
        assertNotNull(reason);
        assertTrue(reason.indexOf("This is the fault reason.") > -1);
        assertTrue(fc.equals(SOAPConstants.SOAP_RECEIVER_FAULT));
    } catch (SOAPException e) {
        fail("Caught unexpected SOAPException");
    }
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:27,代碼來源:SOAPFactoryTest.java

示例3: _testGetFaultCodeAsQName

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
public void _testGetFaultCodeAsQName() throws Exception {
    //MessageFactory fac = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    MessageFactory fac = MessageFactory.newInstance();

    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();
    soapFault.addFaultReasonText("myReason", new Locale("en"));
    soapFault.setFaultCode("mycode");
    soapMessage.saveChanges();

    QName qname = soapFault.getFaultCodeAsQName();
    assertNotNull(qname);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:19,代碼來源:SOAPFaultTest.java

示例4: testSetGetFaultCodeAsName1

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testSetGetFaultCodeAsName1() throws Exception {
    SOAPFactory fac = SOAPFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
    SOAPFault sf = fac.createFault();

    Name name = fac.createName("myfault", "flt", "http://example.com");
    sf.setFaultCode(name);
    
    Name name2 = sf.getFaultCodeAsName();            
    assertNotNull(name2);
    assertEquals(name.getLocalName(), name2.getLocalName());
    assertEquals(name.getPrefix(), name2.getPrefix());
    assertEquals(name.getURI(), name2.getURI());
    
    QName name3 = sf.getFaultCodeAsQName();            
    assertNotNull(name3);
    assertEquals(name.getLocalName(), name3.getLocalPart());
    assertEquals(name.getPrefix(), name3.getPrefix());
    assertEquals(name.getURI(), name3.getNamespaceURI());
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:21,代碼來源:SOAPFaultTest.java

示例5: testSetGetFaultCodeAsName2

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testSetGetFaultCodeAsName2() throws Exception {
    QName qname = SOAPConstants.SOAP_SENDER_FAULT;
    SOAPFactory fac = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    Name name = fac.createName(qname.getLocalPart(),
                               qname.getPrefix(), qname.getNamespaceURI());
    SOAPFault sf = fac.createFault();
    sf.setFaultCode(name);
    
    Name name2 = sf.getFaultCodeAsName();            
    assertNotNull(name2);
    assertEquals(name.getLocalName(), name2.getLocalName());
    assertEquals(name.getPrefix(), name2.getPrefix());
    assertEquals(name.getURI(), name2.getURI());
    
    QName name3 = sf.getFaultCodeAsQName();            
    assertNotNull(name3);
    assertEquals(name.getLocalName(), name3.getLocalPart());
    assertEquals(name.getPrefix(), name3.getPrefix());
    assertEquals(name.getURI(), name3.getNamespaceURI());
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:22,代碼來源:SOAPFaultTest.java

示例6: testSetGetFaultCodeAsQName1

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testSetGetFaultCodeAsQName1() throws Exception {
    SOAPFactory fac = SOAPFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
    SOAPFault sf = fac.createFault();

    QName name = new QName("http://example.com", "myfault", "flt");
    sf.setFaultCode(name);
    
    QName name2 = sf.getFaultCodeAsQName();
    assertNotNull(name2);
    assertEquals(name.getLocalPart(), name2.getLocalPart());
    assertEquals(name.getPrefix(), name2.getPrefix());
    assertEquals(name.getNamespaceURI(), name2.getNamespaceURI());
    
    Name name3 = sf.getFaultCodeAsName();
    assertNotNull(name3);
    assertEquals(name.getLocalPart(), name3.getLocalName());
    assertEquals(name.getPrefix(), name3.getPrefix());
    assertEquals(name.getNamespaceURI(), name3.getURI());
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:21,代碼來源:SOAPFaultTest.java

示例7: testSetGetFaultCodeAsQName2

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
@Validated @Test
public void testSetGetFaultCodeAsQName2() throws Exception {
    QName name = SOAPConstants.SOAP_SENDER_FAULT;
    SOAPFactory fac = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPFault sf = fac.createFault();
    sf.setFaultCode(name);
    
    QName name2 = sf.getFaultCodeAsQName();
    assertNotNull(name2);
    assertEquals(name.getLocalPart(), name2.getLocalPart());
    assertEquals(name.getPrefix(), name2.getPrefix());
    assertEquals(name.getNamespaceURI(), name2.getNamespaceURI());
    
    Name name3 = sf.getFaultCodeAsName();
    assertNotNull(name3);
    assertEquals(name.getLocalPart(), name3.getLocalName());
    assertEquals(name.getPrefix(), name3.getPrefix());
    assertEquals(name.getNamespaceURI(), name3.getURI());
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:20,代碼來源:SOAPFaultTest.java

示例8: SOAP11Fault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
SOAP11Fault(SOAPFault fault) {
    this.faultcode = fault.getFaultCodeAsQName();
    this.faultstring = fault.getFaultString();
    this.faultactor = fault.getFaultActor();
    if (fault.getDetail() != null) {
        detail = new DetailType();
        Iterator iter = fault.getDetail().getDetailEntries();
        while(iter.hasNext()){
            Element fd = (Element)iter.next();
            detail.getDetails().add(fd);
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:14,代碼來源:SOAP11Fault.java

示例9: createSOAP12Fault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
private static Message createSOAP12Fault(SOAPVersion soapVersion, Throwable e, Object detail, CheckedExceptionImpl ce, QName faultCode) {
    SOAPFaultException soapFaultException = null;
    CodeType code = null;
    String faultString = null;
    String faultRole = null;
    String faultNode = null;
    Throwable cause = e.getCause();
    if (e instanceof SOAPFaultException) {
        soapFaultException = (SOAPFaultException) e;
    } else if (cause != null && cause instanceof SOAPFaultException) {
        soapFaultException = (SOAPFaultException) e.getCause();
    }
    if (soapFaultException != null) {
        SOAPFault fault = soapFaultException.getFault();
        QName soapFaultCode = fault.getFaultCodeAsQName();
        if(soapFaultCode != null){
            faultCode = soapFaultCode;
            code = new CodeType(faultCode);
            Iterator iter = fault.getFaultSubcodes();
            boolean first = true;
            SubcodeType subcode = null;
            while(iter.hasNext()){
                QName value = (QName)iter.next();
                if(first){
                    SubcodeType sct = new SubcodeType(value);
                    code.setSubcode(sct);
                    subcode = sct;
                    first = false;
                    continue;
                }
                subcode = fillSubcodes(subcode, value);
            }
        }
        faultString = soapFaultException.getFault().getFaultString();
        faultRole = soapFaultException.getFault().getFaultActor();
        faultNode = soapFaultException.getFault().getFaultNode();
    }

    if (faultCode == null) {
        faultCode = getDefaultFaultCode(soapVersion);
        code = new CodeType(faultCode);
    }else if(code == null){
        code = new CodeType(faultCode);
    }

    if (faultString == null) {
        faultString = e.getMessage();
        if (faultString == null) {
            faultString = e.toString();
        }
    }

    ReasonType reason = new ReasonType(faultString);
    Element detailNode = null;
    QName firstEntry = null;
    if (detail == null && soapFaultException != null) {
        detailNode = soapFaultException.getFault().getDetail();
        firstEntry = getFirstDetailEntryName((Detail)detailNode);
    } else if(detail != null){
        try {
            DOMResult dr = new DOMResult();
            ce.getBond().marshal(detail, dr);
            detailNode = (Element)dr.getNode().getFirstChild();
            firstEntry = getFirstDetailEntryName(detailNode);
        } catch (JAXBException e1) {
            //Should we throw Internal Server Error???
            faultString = e.getMessage();
        }
    }

    SOAP12Fault soap12Fault = new SOAP12Fault(code, reason, faultNode, faultRole, detailNode);

    //Don't fill the stacktrace for Service specific exceptions.
    if(ce == null) {
        soap12Fault.captureStackTrace(e);
    }
    Message msg = JAXBMessage.create(JAXB_CONTEXT, soap12Fault, soapVersion);
    return new FaultMessage(msg, firstEntry);
}
 
開發者ID:RedlineResearch,項目名稱:OLD-OpenJDK8,代碼行數:80,代碼來源:SOAPFaultBuilder.java

示例10: createSOAP12Fault

import javax.xml.soap.SOAPFault; //導入方法依賴的package包/類
private static Message createSOAP12Fault(SOAPVersion soapVersion, Throwable e, Object detail, CheckedExceptionImpl ce, QName faultCode) {
    SOAPFaultException soapFaultException = null;
    CodeType code = null;
    String faultString = null;
    String faultRole = null;
    String faultNode = null;
    Throwable cause = e.getCause();
    if (e instanceof SOAPFaultException) {
        soapFaultException = (SOAPFaultException) e;
    } else if (cause != null && cause instanceof SOAPFaultException) {
        soapFaultException = (SOAPFaultException) e.getCause();
    }
    if (soapFaultException != null) {
        SOAPFault fault = soapFaultException.getFault();
        QName soapFaultCode = fault.getFaultCodeAsQName();
        if(soapFaultCode != null){
            faultCode = soapFaultCode;
            code = new CodeType(faultCode);
            Iterator iter = fault.getFaultSubcodes();
            boolean first = true;
            SubcodeType subcode = null;
            while(iter.hasNext()){
                QName value = (QName)iter.next();
                if(first){
                    SubcodeType sct = new SubcodeType(value);
                    code.setSubcode(sct);
                    subcode = sct;
                    first = false;
                    continue;
                }
                subcode = fillSubcodes(subcode, value);
            }
        }
        faultString = soapFaultException.getFault().getFaultString();
        faultRole = soapFaultException.getFault().getFaultActor();
        faultNode = soapFaultException.getFault().getFaultNode();
    }

    if (faultCode == null) {
        faultCode = getDefaultFaultCode(soapVersion);
        code = new CodeType(faultCode);
    }else if(code == null){
        code = new CodeType(faultCode);
    }

    if (faultString == null) {
        faultString = e.getMessage();
        if (faultString == null) {
            faultString = e.toString();
        }
    }

    ReasonType reason = new ReasonType(faultString);
    Element detailNode = null;
    QName firstEntry = null;
    if (detail == null && soapFaultException != null) {
        detailNode = soapFaultException.getFault().getDetail();
        firstEntry = getFirstDetailEntryName((Detail)detailNode);
    } else if(detail != null){
        try {
            DOMResult dr = new DOMResult();
            ce.getBridge().marshal(detail, dr);
            detailNode = (Element)dr.getNode().getFirstChild();
            firstEntry = getFirstDetailEntryName(detailNode);
        } catch (JAXBException e1) {
            //Should we throw Internal Server Error???
            faultString = e.getMessage();
            faultCode = getDefaultFaultCode(soapVersion);
        }
    }

    SOAP12Fault soap12Fault = new SOAP12Fault(code, reason, faultNode, faultRole, detailNode);

    //Don't fill the stacktrace for Service specific exceptions.
    if(ce == null) {
        soap12Fault.captureStackTrace(e);
    }
    Message msg = JAXBMessage.create(JAXB_CONTEXT, soap12Fault, soapVersion);
    return new FaultMessage(msg, firstEntry);
}
 
開發者ID:alexkasko,項目名稱:openjdk-icedtea7,代碼行數:81,代碼來源:SOAPFaultBuilder.java


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