• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Detail类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getSOAPMessage

import javax.xml.soap.Detail; //导入依赖的package包/类
/** 
 * Get SOAP Fault message from the information given.
 * 
 * @return <code>SOAPMessage</code> object containing Fault element.
 */
public SOAPMessage getSOAPMessage() {
    try {
        final MessageFactory mf = MessageFactory.newInstance();
        final SOAPMessage message = (SOAPMessage)mf.createMessage();
        
        // set default SOAP XML declaration and encoding
        message.setProperty(SOAPMessage.WRITE_XML_DECLARATION, 
        		Boolean.toString(EbxmlMessage.WRITE_XML_DECLARATION));
        message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, 
        		EbxmlMessage.CHARACTER_SET_ENCODING);
        
        final SOAPPart part = message.getSOAPPart();
        final SOAPEnvelope envelope = part.getEnvelope();
        final SOAPBody body = envelope.getBody();
        final SOAPFault fault = body.addFault();

        fault.setFaultCode(errorCode);
        fault.setFaultString(errorString);
        if (faultActor != null) {
            fault.setFaultActor(faultActor);
        }
        if (detail != null) {
            Detail d = fault.addDetail();
            Name name = envelope.createName(ELEMENT_ERROR, 
                NAMESPACE_PREFIX_CECID, NAMESPACE_URI_CECID);
            DetailEntry entry = d.addDetailEntry(name);
            entry.addTextNode(detail);
        }

        return message;
    }
    catch (SOAPException e) {
    }

    return null;
}
 
开发者ID:cecid,项目名称:hermes,代码行数:42,代码来源:SOAPValidationException.java


示例17: serializeFaultMessage

import javax.xml.soap.Detail; //导入依赖的package包/类
public static void serializeFaultMessage(Detail detail, FaultMessage faultMessage, PrismContext prismContext, Trace logger) {
       try {
		BeanMarshaller marshaller = ((PrismContextImpl) prismContext).getBeanMarshaller();
		XNode faultMessageXnode = marshaller.marshall(faultMessage.getFaultInfo());			// TODO
           RootXNode xroot = new RootXNode(SchemaConstants.FAULT_MESSAGE_ELEMENT_NAME, faultMessageXnode);
           xroot.setExplicitTypeDeclaration(true);
           QName faultType = prismContext.getSchemaRegistry().determineTypeForClass(faultMessage.getFaultInfo().getClass());
           xroot.setTypeQName(faultType);
		((PrismContextImpl) prismContext).getParserDom().serializeUnderElement(xroot, SchemaConstants.FAULT_MESSAGE_ELEMENT_NAME, detail);
       } catch (SchemaException e) {
           logger.error("Error serializing fault message (SOAP fault detail): {}", e.getMessage(), e);
       }
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:14,代码来源:MiscSchemaUtil.java


示例18: testProviderMessage

import javax.xml.soap.Detail; //导入依赖的package包/类
@Test
@RunAsClient
public void testProviderMessage() throws Exception
{
   SOAPMessage reqMsg = getRequestMessage();
   URL epURL = new URL(baseURL + "/jaxws-jbws1815/ProviderImpl");
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();
   Detail detail = resEnv.getBody().getFault().getDetail();
   assertNotNull(detail);
   SOAPElement exception = (SOAPElement)detail.getDetailEntries().next();
   assertNotNull(exception);
   assertEquals("MyWSException", exception.getElementQName().getLocalPart());
   assertEquals("http://www.my-company.it/ws/my-test", exception.getElementQName().getNamespaceURI());
   SOAPElement message = (SOAPElement)exception.getChildElements().next();
   assertNotNull(message);
   assertEquals("message", message.getNodeName());
   assertEquals("This is a faked error", message.getValue());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:21,代码来源:JBWS1815TestCase.java


示例19: replaceByJPlagException

import javax.xml.soap.Detail; //导入依赖的package包/类
/**
 * Manually builds up a JPlagException SOAP message and replaces the
 * original one with it
 */
public void replaceByJPlagException(SOAPMessageContext smsg, String desc, String rep) {
	try {
		SOAPMessage msg = smsg.getMessage();
		SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();

		/*
		 * Remove old header andy body
		 */

		SOAPHeader oldheader = envelope.getHeader();
		if (oldheader != null)
			oldheader.detachNode();
		SOAPBody oldbody = envelope.getBody();
		if (oldbody != null)
			oldbody.detachNode();

		SOAPBody sb = envelope.addBody();
		SOAPFault sf = sb.addFault(envelope.createName("Server", "env", SOAPConstants.URI_NS_SOAP_ENVELOPE),
				"jplagWebService.server.JPlagException");
		Detail detail = sf.addDetail();
		DetailEntry de = detail.addDetailEntry(envelope.createName("JPlagException", "ns0", JPLAG_WEBSERVICE_BASE_URL + "types"));

		SOAPElement e = de.addChildElement("exceptionType");
		e.addTextNode("accessException");

		e = de.addChildElement("description");
		e.addTextNode(desc);

		e = de.addChildElement("repair");
		e.addTextNode(rep);
	} catch (SOAPException x) {
		x.printStackTrace();
	}
}
 
开发者ID:jplag,项目名称:jplag,代码行数:39,代码来源:JPlagServerAccessHandler.java


示例20: newSOAPFault

import javax.xml.soap.Detail; //导入依赖的package包/类
private SOAPFault newSOAPFault(String errorMsg) {
try {
    MessageFactory mf = MessageFactory
	    .newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);

    SOAPMessage msg = mf.createMessage();

    SOAPFault fault = msg.getSOAPBody().addFault();

    QName faultName = new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE,
	    "Client");
    fault.setFaultCode(faultName);
    fault.setFaultString(errorMsg);

    Detail detail = fault.addDetail();

    QName entryName = new QName(
	    "http://abhijitsarkar.name/webservices/jaxws/provider/",
	    "error", "ns");
    DetailEntry entry = detail.addDetailEntry(entryName);
    entry.addTextNode(errorMsg);

    return fault;
} catch (Exception e) {
    throw new WebServiceException(e.getMessage(), e);
}
   }
 
开发者ID:asarkar,项目名称:jax-ws,代码行数:28,代码来源:JAXWSProviderService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OnChartGestureListener类代码示例发布时间:2022-05-21
下一篇:
Java Handler类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap