当前位置: 首页>>代码示例>>Java>>正文


Java Detail类代码示例

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


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

示例1: _testQuick

import javax.xml.soap.Detail; //导入依赖的package包/类
public void _testQuick() throws Exception {
    MessageFactory msgfactory = MessageFactory.newInstance();
    SOAPFactory factory = SOAPFactory.newInstance();
    SOAPMessage outputmsg = msgfactory.createMessage();
    String valueCode = "faultcode";
    String valueString = "faultString";
    SOAPFault fault = outputmsg.getSOAPPart().getEnvelope().getBody().addFault();
    fault.setFaultCode(valueCode);
    fault.setFaultString(valueString);
    Detail detail = fault.addDetail();
    detail.addDetailEntry(factory.createName("Hello"));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    if (outputmsg.saveRequired()) {
        outputmsg.saveChanges();
    }
    outputmsg.writeTo(baos);
    String xml = new String(baos.toByteArray());
    assertTrue(xml.indexOf("Hello") != -1);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:20,代码来源:SOAPFaultTest.java

示例2: getProtocolException

import javax.xml.soap.Detail; //导入依赖的package包/类
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.getSOAPFactory().createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new ServerSOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SOAP11Fault.java

示例3: invoke

import javax.xml.soap.Detail; //导入依赖的package包/类
@Override
public DOMSource invoke(DOMSource request) {
    try {
        return invokeAllowingFaults(request);
    } catch (FaultMessage faultMessage) {
        try {
            SOAPFactory factory = SOAPFactory.newInstance();
            SOAPFault soapFault = factory.createFault();
            soapFault.setFaultCode(SOAP11_FAULTCODE_SERVER);           // todo here is a constant until we have a mechanism to determine the correct value (client / server)
            soapFault.setFaultString(faultMessage.getMessage());
            Detail detail = soapFault.addDetail();
            serializeFaultMessage(detail, faultMessage);
            // fault actor?
            // stack trace of the outer exception (FaultMessage) is unimportant, because it is always created at one place
            // todo consider providing stack trace of the inner exception
            //Detail detail = soapFault.addDetail();
            //detail.setTextContent(getStackTraceAsString(faultMessage));
            throw new SOAPFaultException(soapFault);
        } catch (SOAPException e) {
            throw new RuntimeException("SOAP Exception: " + e.getMessage(), e);
        }
    }
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:24,代码来源:ModelWebServiceRaw.java

示例4: invoke

import javax.xml.soap.Detail; //导入依赖的package包/类
public SOAPMessage invoke(SOAPMessage requestSoapMessage)
   {
      SOAPFault theSOAPFault;
      try {
         theSOAPFault = SOAPFactory.newInstance().createFault();
         Detail soapFaultDetail = theSOAPFault.addDetail();
         SOAPElement myFaultElement = soapFaultDetail.addChildElement(new QName("http://www.my-company.it/ws/my-test", "MyWSException"));
         SOAPElement myMessageElement = myFaultElement.addChildElement(new QName("http://www.my-company.it/ws/my-test", "message"));
//         myMessageElement.setNodeValue("This is a faked error"); //wrong: myMessageElement is not a text node
         myMessageElement.setValue("This is a faked error"); //right: this creates a text node and gives it a text value
      } catch (SOAPException se) {
         se.printStackTrace();
         throw new RuntimeException("Something unexpected happened!");
      }
      throw new SOAPFaultException(theSOAPFault);
   }
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:17,代码来源:ProviderImpl.java

示例5: throwSoapFault

import javax.xml.soap.Detail; //导入依赖的package包/类
private static void throwSoapFault(String faultMessage, String ExceptionDetail, String SonosError) throws RuntimeException {
SOAPFault soapFault;
try {
          soapFault = SOAPFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createFault();
          soapFault.setFaultString(faultMessage);
          soapFault.setFaultCode(new QName(faultMessage));
          
          if(!ExceptionDetail.isEmpty() && !SonosError.isEmpty()) {            
          	Detail detail = soapFault.addDetail();
          	SOAPElement el1 = detail.addChildElement("ExceptionDetail");
  	        el1.setValue(ExceptionDetail);
           SOAPElement el = detail.addChildElement("SonosError");
           el.setValue(SonosError);	            
          }
          
      } catch (Exception e2) {
          throw new RuntimeException("Problem processing SOAP Fault on service-side." + e2.getMessage());
      }
          throw new SOAPFaultException(soapFault);

  }
 
开发者ID:bertique,项目名称:SonosNPROneServer,代码行数:22,代码来源:SonosService.java

示例6: addDetail

import javax.xml.soap.Detail; //导入依赖的package包/类
public Detail addDetail() throws SOAPException {
    if (isDetailAdded) {
        throw new SOAPException("This SOAPFault already contains a Detail element. " +
                "Please remove the existing Detail element before " +
                "calling addDetail()");
    }

    SOAPFaultDetail omDetail;
    SOAPFactory factory = (SOAPFactory)this.element.getOMFactory();
    if (factory instanceof SOAP11Factory) {
        omDetail = new SOAP11FaultDetailImpl(this.fault,
                                             factory);
    } else {
        omDetail = new SOAP12FaultDetailImpl(this.fault,
                                             factory);
    }
    Detail saajDetail = new DetailImpl(omDetail);
    ((NodeImpl)fault.getDetail()).setUserData(SAAJ_NODE, saajDetail, null);
    isDetailAdded = true;
    return saajDetail;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:SOAPFaultImpl.java

示例7: setEncodingStyle

import javax.xml.soap.Detail; //导入依赖的package包/类
/**
 * Sets the encoding style for this SOAPElement object to one specified.
 *
 * @param encodingStyle - a String giving the encoding style
 * @throws IllegalArgumentException
 *          - if there was a problem in the encoding style being set. SOAPException - if setting
 *          the encodingStyle is invalid for this SOAPElement.
 */
public void setEncodingStyle(String encodingStyle) throws SOAPException {
    if (this.element.getOMFactory() instanceof SOAP11Factory) {
        try {
            URI uri = new URI(encodingStyle);
            if (!(this instanceof SOAPEnvelope)) {
                if (!encodingStyle.equals(SOAPConstants.URI_NS_SOAP_ENCODING)) {
                    throw new IllegalArgumentException(
                            "Invalid Encoding style : " + encodingStyle);
                }
            }
            this.encodingStyle = encodingStyle;
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Invalid Encoding style : "
                    + encodingStyle + ":" + e);
        }
    } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
        if (this instanceof SOAPHeader || this instanceof SOAPBody ||
                this instanceof SOAPFault ||
                this instanceof SOAPFaultElement || this instanceof SOAPEnvelope ||
                this instanceof Detail) {
            throw new SOAPException("EncodingStyle attribute cannot appear in : " + this);
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:33,代码来源:SOAPElementImpl.java

示例8: _testFaults2

import javax.xml.soap.Detail; //导入依赖的package包/类
public void _testFaults2() throws Exception {
    SOAPEnvelope envelope = getSOAPEnvelope();
    SOAPBody body = envelope.getBody();
    SOAPFault fault = body.addFault();

    assertTrue(body.getFault() != null);

    Detail d1 = fault.addDetail();
    Name name = envelope.createName("GetLastTradePrice", "WOMBAT",
                                    "http://www.wombat.org/trader");
    d1.addDetailEntry(name);

    Detail d2 = fault.getDetail();
    assertTrue(d2 != null);
    Iterator i = d2.getDetailEntries();
    assertTrue(getIteratorCount(i) == 1);
    i = d2.getDetailEntries();
    while (i.hasNext()) {
        DetailEntry de = (DetailEntry)i.next();
        assertEquals(de.getElementName(), name);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:SOAPEnvelopeTest.java

示例9: testCreateDetail

import javax.xml.soap.Detail; //导入依赖的package包/类
@Validated @Test
public void testCreateDetail() {
    try {
        SOAPFactory sf = SOAPFactory.newInstance();
        if (sf == null) {
            fail("SOAPFactory was null");
        }
        Detail d = sf.createDetail();
        if (d == null) {
            fail("Detail was null");
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail("Unexpected Exception " + e);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:SOAPFactoryTest.java

示例10: testHasDetail

import javax.xml.soap.Detail; //导入依赖的package包/类
@Validated @Test
public void testHasDetail() 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();
    Detail detail = soapFault.addDetail();
    detail.setAttribute("test", "myvalue");
    soapMessage.saveChanges();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:SOAPFaultTest.java

示例11: testAddDetailEntry2

import javax.xml.soap.Detail; //导入依赖的package包/类
@Validated @Test
public void testAddDetailEntry2() throws Exception {
    msg = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
    sp = msg.getSOAPPart();
    envelope = sp.getEnvelope();
    body = envelope.getBody();

    //Add a SOAPFault object to the SOAPBody
    SOAPFault sf = body.addFault();
    //Add a Detail object to the SOAPFault object
    Detail d = sf.addDetail();
    QName name = new QName("http://www.wombat.org/trader",
                           "GetLastTradePrice", "WOMBAT");
    //Add a DetailEntry object to the Detail object
    DetailEntry de = d.addDetailEntry(name);
    //Successfully created DetailEntry object
    assertNotNull(de);
    assertTrue(de instanceof DetailEntry);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:20,代码来源:SAAJDetailTest.java

示例12: detailChildrenIterator

import javax.xml.soap.Detail; //导入依赖的package包/类
/**
 * It can either e within an extra tag, or directly.
 */
private Iterator detailChildrenIterator(Detail detail) {
    /*
    sb.append("<ns2:AccessDeniedWebServiceException xmlns:ns2=\"http://exceptionthrower.system.services.v4_0.soap.server.nameapi.org/\">");
    sb.append("<blame>CLIENT</blame>");
    sb.append("<errorCode>2101</errorCode>");
    sb.append("<faultCause>AccessDenied</faultCause>");
     */

    DetailEntry firstDetailEntry = getFirstDetailEntry(detail);
    if (firstDetailEntry!=null) {
        String localName = firstDetailEntry.getElementName().getLocalName();
        if (localName.endsWith("Exception")) {
            //got a subtag
            return firstDetailEntry.getChildElements();
        }
    }
    return detail.getDetailEntries();
}
 
开发者ID:optimaize,项目名称:anythingworks,代码行数:22,代码来源:SoapFaultExceptionTranslator.java

示例13: getProtocolException

import javax.xml.soap.Detail; //导入依赖的package包/类
protected Throwable getProtocolException() {
    try {
        SOAPFault fault = SOAPVersion.SOAP_11.saajSoapFactory.createFault(faultstring, faultcode);
        fault.setFaultActor(faultactor);
        if(detail != null){
            Detail d = fault.addDetail();
            for(Element det : detail.getDetails()){
                Node n = fault.getOwnerDocument().importNode(det, true);
                d.appendChild(n);
            }
        }
        return new SOAPFaultException(fault);
    } catch (SOAPException e) {
        throw new WebServiceException(e);
    }
}
 
开发者ID:alexkasko,项目名称:openjdk-icedtea7,代码行数:17,代码来源:SOAP11Fault.java

示例14: getFirstDetailEntryName

import javax.xml.soap.Detail; //导入依赖的package包/类
private static @Nullable QName getFirstDetailEntryName(@Nullable Detail detail) {
    if (detail != null) {
        Iterator<DetailEntry> it = detail.getDetailEntries();
        if (it.hasNext()) {
            DetailEntry entry = it.next();
            return getFirstDetailEntryName(entry);
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:SOAPFaultBuilder.java

示例15: addFault

import javax.xml.soap.Detail; //导入依赖的package包/类
/**
 * Adds a SOAP fault to the SOAP message of this response.
 * 
 * @param cause the exception cause.
 * @return the SOAP fault which has been added to the SOAP message. null if
 *         there is no SOAP message in this response or the fault has
 *         already been added.
 * @throws SOAPException a SOAP error occurred when adding the the fault.
 */
public SOAPFault addFault(Throwable cause) throws SOAPException {
    if ((cause instanceof SOAPRequestException)
            && ((SOAPRequestException) cause).isSOAPFault()) {
        SOAPFaultException sfe = ((SOAPRequestException) cause)
                .getSOAPFault();
        SOAPFault fault = addFault(sfe.getFaultCode(), sfe.getFaultActor(),
                sfe.getFaultString());
        if (fault != null && sfe.hasDetailEntries()) {
            Detail detail = fault.addDetail();
            Iterator detailEntries = sfe.getDetailEntryNames();
            while (detailEntries.hasNext()) {
                Name entryName = (Name) detailEntries.next();
                DetailEntry entry = detail.addDetailEntry(entryName);

                Object entryValue = sfe.getDetailEntryValue(entryName);
                if (entryValue instanceof SOAPElement) {
                    entry.addChildElement((SOAPElement) entryValue);
                }
                else {
                    entry.addTextNode(entryValue.toString());
                }
            }
        }
        return fault;
    }
    else {
        return addFault(SOAPFaultException.SOAP_FAULT_SERVER, null, cause
                .toString());
    }
}
 
开发者ID:cecid,项目名称:hermes,代码行数:40,代码来源:SOAPResponse.java


注:本文中的javax.xml.soap.Detail类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。