Java 类javax.xml.soap.SOAPConstants 实例源码

项目:OpenJSharp    文件:SOAPPart1_1Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
项目:OpenJSharp    文件:SAAJMetaFactoryImpl.java   
protected  MessageFactory newMessageFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "MessageFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating MessageFactory");
    }
}
项目:OpenJSharp    文件:SAAJMetaFactoryImpl.java   
protected  SOAPFactory newSOAPFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "SOAPFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating SOAPFactory");
    }
}
项目:OpenJSharp    文件:SOAPPart1_2Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
项目:openjdk-jdk10    文件:SOAPPart1_1Impl.java   
@Override
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
项目:openjdk-jdk10    文件:SAAJMetaFactoryImpl.java   
@Override
protected  MessageFactory newMessageFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "MessageFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating MessageFactory");
    }
}
项目:openjdk-jdk10    文件:SAAJMetaFactoryImpl.java   
@Override
protected  SOAPFactory newSOAPFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "SOAPFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating SOAPFactory");
    }
}
项目:openjdk-jdk10    文件:SOAPPart1_2Impl.java   
@Override
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
项目:openjdk-jdk10    文件:Fault1_2Impl.java   
@Override
protected void checkIfStandardFaultCode(String faultCode, String uri)
    throws SOAPException {
    QName qname = new QName(uri, faultCode);
    if (SOAPConstants.SOAP_DATAENCODINGUNKNOWN_FAULT.equals(qname) ||
        SOAPConstants.SOAP_MUSTUNDERSTAND_FAULT.equals(qname) ||
        SOAPConstants.SOAP_RECEIVER_FAULT.equals(qname) ||
        SOAPConstants.SOAP_SENDER_FAULT.equals(qname) ||
        SOAPConstants.SOAP_VERSIONMISMATCH_FAULT.equals(qname))
        return;
    log.log(
        Level.SEVERE,
        "SAAJ0435.ver1_2.code.not.standard",
        qname);
    throw new SOAPExceptionImpl(qname + " is not a standard Code value");
}
项目:openjdk-jdk10    文件:Fault1_2Impl.java   
@Override
public SOAPElement addChildElement(SOAPElement element)
    throws SOAPException {
    String localName = element.getLocalName();
    if ("Detail".equalsIgnoreCase(localName)) {
        if (hasDetail()) {
            log.severe("SAAJ0436.ver1_2.detail.exists.error");
            throw new SOAPExceptionImpl("Cannot add Detail, Detail already exists");
        }
        String uri = element.getElementQName().getNamespaceURI();
        if (!uri.equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
            log.severe("SAAJ0437.ver1_2.version.mismatch.error");
            throw new SOAPExceptionImpl("Cannot add Detail, Incorrect SOAP version specified for Detail element");
        }
    }
    if (element instanceof Detail1_2Impl) {
        Element importedElement = importElement(element);
        addNode(importedElement);
        return convertToSoapElement(importedElement);
    } else
        return super.addChildElement(element);
}
项目:openjdk9    文件:SOAPPart1_1Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
项目:openjdk9    文件:SAAJMetaFactoryImpl.java   
protected  MessageFactory newMessageFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "MessageFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating MessageFactory");
    }
}
项目:openjdk9    文件:SAAJMetaFactoryImpl.java   
protected  SOAPFactory newSOAPFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "SOAPFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating SOAPFactory");
    }
}
项目:openjdk9    文件:SOAPPart1_2Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
项目:lookaside_java-1.8.0-openjdk    文件:SOAPPart1_1Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
项目:lookaside_java-1.8.0-openjdk    文件:SAAJMetaFactoryImpl.java   
protected  MessageFactory newMessageFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "MessageFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating MessageFactory");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SAAJMetaFactoryImpl.java   
protected  SOAPFactory newSOAPFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "SOAPFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating SOAPFactory");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:SOAPPart1_2Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
项目:jbossws-cxf    文件:JBWS2278TestCase.java   
@Before
public void setup() throws Exception
{
   if (port11 == null) {
      URL wsdlURL = new URL(baseURL + "/soap11?wsdl");
      QName serviceName = new QName("http://org.jboss.test.ws/jbws2278", "TestService");

      Service service = Service.create(wsdlURL, serviceName);
      port11 = service.getPort(new QName("http://org.jboss.test.ws/jbws2278", "TestEndpointSoap11Port"), TestEndpoint.class);
      port12 = service.getPort(new QName("http://org.jboss.test.ws/jbws2278", "TestEndpointSoap12Port"), TestEndpoint.class);

      @SuppressWarnings("rawtypes")
      List<Handler> handlerChain11 = new ArrayList<Handler>();
      handlerChain11.add(new TestHandler(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, SOAPConstants.SOAP_1_1_CONTENT_TYPE));
      ((BindingProvider)port11).getBinding().setHandlerChain(handlerChain11);

      @SuppressWarnings("rawtypes")
      List<Handler> handlerChain12 = new ArrayList<Handler>();
      handlerChain12.add(new TestHandler(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, SOAPConstants.SOAP_1_2_CONTENT_TYPE));
      ((BindingProvider)port12).getBinding().setHandlerChain(handlerChain12);
   }
}
项目:jbossws-cxf    文件:SOAPBindingTestCase.java   
@Test
@RunAsClient
public void testClientAccess() throws Exception
{
   URL wsdlURL = new URL(baseURL + "?wsdl");
   QName qname = new QName("http://org.jboss.ws/jaxws/binding", "SOAPEndpointService");
   Service service = Service.create(wsdlURL, qname);
   SOAPEndpoint port = service.getPort(SOAPEndpoint.class);

   BindingProvider provider = (BindingProvider)port;
   @SuppressWarnings("rawtypes")
   List<Handler> handlerChain = new ArrayList<Handler>();
   handlerChain.addAll(provider.getBinding().getHandlerChain());
   handlerChain.add(new ClientHandler());
   handlerChain.add(new ClientHandler2());
   provider.getBinding().setHandlerChain(handlerChain);

   String nsURI = port.namespace();
   assertEquals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE + ":" + SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, nsURI);
}
项目:jbossws-cxf    文件:EndpointImpl.java   
public void throwSoapFaultException()
{
   // This should be thrown as-is
   try
   {
      SOAPFactory factory = SOAPFactory.newInstance();
      SOAPFault fault = factory.createFault("this is a fault string!", SOAPConstants.SOAP_VERSIONMISMATCH_FAULT);
      fault.setFaultActor("mr.actor");
      fault.addDetail().addChildElement("test");
      throw new SOAPFaultException(fault);
   }
   catch (SOAPException s)
   {
      throw new RuntimeException(s);
   }
}
项目:jbossws-cxf    文件:JBWS3945EndpointImpl.java   
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);
   }
}
项目:jbossws-cxf    文件:SOAP12EndpointImpl.java   
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);
   }
}
项目:jbossws-cxf    文件:MultipartContentTypeTestCase.java   
@Test
@RunAsClient
public void testSendMultipartSoapMessage() throws Exception {
   final MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
   final SOAPMessage msg = msgFactory.createMessage();
   final SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(
      new QName("urn:ledegen:soap-attachment:1.0", "echoImage"));
   bodyElement.addTextNode("cid:" + IN_IMG_NAME);

   final AttachmentPart ap = msg.createAttachmentPart();
   ap.setDataHandler(getResource("saaj/jbws3857/" + IN_IMG_NAME));
   ap.setContentId(IN_IMG_NAME);
   msg.addAttachmentPart(ap);

   final SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
   final SOAPConnection connection = conFactory.createConnection();
   final SOAPMessage response = connection.call(msg, new URL("http://" + baseURL.getHost()+ ":" + baseURL.getPort() + "/" + PROJECT_NAME + "/testServlet"));

   final String contentTypeWeHaveSent = getBodyElementTextValue(response);
   assertContentTypeStarts("multipart/related", contentTypeWeHaveSent);
}
项目:SonosNPROneServer    文件:SonosService.java   
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);

  }
项目:onvif-java-lib    文件:SOAP.java   
protected SOAPMessage createSoapMessage(Object soapRequestElem, boolean needAuthentification) throws SOAPException, ParserConfigurationException,
        JAXBException {
    MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage soapMessage = messageFactory.createMessage();

    Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
    Marshaller marshaller = JAXBContext.newInstance(soapRequestElem.getClass()).createMarshaller();
    marshaller.marshal(soapRequestElem, document);
    soapMessage.getSOAPBody().addDocument(document);

    // if (needAuthentification)
    createSoapHeader(soapMessage);

    soapMessage.saveChanges();
    return soapMessage;
}
项目:infobip-open-jdk-8    文件:SOAPPart1_1Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
项目:infobip-open-jdk-8    文件:SAAJMetaFactoryImpl.java   
protected  MessageFactory newMessageFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "MessageFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating MessageFactory");
    }
}
项目:infobip-open-jdk-8    文件:SAAJMetaFactoryImpl.java   
protected  SOAPFactory newSOAPFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "SOAPFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating SOAPFactory");
    }
}
项目:infobip-open-jdk-8    文件:SOAPPart1_2Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
项目:incubator-taverna-common-activities    文件:TypeDescriptors.java   
/**
 * Builds a type descriptor for a "RPC" parameter.
 * 
 * @param typeName an XML type name of the parameter.
 * @return a Type Descriptor for the parameter.
 */
public TypeDescriptor getTypeDescriptor(QName typeName) {
    XmlSchemaType xmlSchemaType = schemas.getTypeByQName(typeName);

    if (xmlSchemaType == null) {
        return null;
    }

    TypeDescriptor typeDesc;
    if (SOAPConstants.URI_NS_SOAP_ENCODING.equals(typeName.getNamespaceURI()) &&
        "Array".equals(typeName.getLocalPart())) {
        typeDesc = new ArrayTypeDescriptor();
    } else {
        typeDesc = getTypeDescriptor(xmlSchemaType);
    }

    typeDesc.setType(typeName.getLocalPart());

    return typeDesc;
}
项目:incubator-taverna-common-activities    文件:EncodedBodyBuilder.java   
@Override
public SOAPElement build(Map inputMap) throws WSDLException,
        ParserConfigurationException, SOAPException, IOException,
        SAXException, UnknownOperationException {

    SOAPElement result = super.build(inputMap);

    for (Iterator iterator = namespaceMappings.keySet().iterator(); iterator.hasNext();) {
        String namespaceURI = (String) iterator.next();
        String ns = namespaceMappings.get(namespaceURI);
        result.addNamespaceDeclaration(ns, namespaceURI);
    }

               result.setAttributeNS(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "soapenv:encodingStyle", SOAPConstants.URI_NS_SOAP_ENCODING);

    return result;
}
项目:switchyard    文件:SOAPMessageComposerTest.java   
@Test
public void testCopyNamespacesOnFaultSOAP11() throws Exception {
    _composer.setCopyNamespaces(true);
    SOAPMessage soapMessage = SOAPUtil.createMessage(javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING);
    soapMessage.getSOAPPart().getEnvelope().addNamespaceDeclaration("foobarns", "urn:foobarns");
    soapMessage.getSOAPBody().addFault(new QName(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, "Server"), "my fault string");
    logger.info(String.format("before compose:[\n%s]", XMLHelper.toPretty(soapMessage.getSOAPPart())));

    SOAPBindingData sbd = new SOAPBindingData(soapMessage);
    Node res = _composer.compose(sbd, _exchange).getContent(Node.class);
    logger.info(String.format("after compose:[\n%s]", XMLHelper.toPretty(res)));
    String envPrefix = soapMessage.getSOAPPart().getEnvelope().getPrefix();
    String envNS = soapMessage.getSOAPPart().getEnvelope().getNamespaceURI(envPrefix);
    String resNS = res.lookupNamespaceURI(envPrefix);
    Assert.assertEquals(envNS, resNS);
    Assert.assertEquals("urn:foobarns", res.lookupNamespaceURI("foobarns"));
}
项目:switchyard    文件:SOAPMessageComposerTest.java   
@Test
public void testCopyNamespacesOnFaultSOAP12() throws Exception {
    _composer.setCopyNamespaces(true);
    SOAPMessage soapMessage = SOAPUtil.createMessage(javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING);
    soapMessage.getSOAPPart().getEnvelope().addNamespaceDeclaration("foobarns", "urn:foobarns");
    soapMessage.getSOAPBody().addFault(new QName(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, "Receiver"), "my fault string");
    logger.info(String.format("before compose:[\n%s]", XMLHelper.toPretty(soapMessage.getSOAPPart())));

    SOAPBindingData sbd = new SOAPBindingData(soapMessage);
    Node res = _composer.compose(sbd, _exchange).getContent(Node.class);
    logger.info(String.format("after compose:[\n%s]", XMLHelper.toPretty(res)));
    String envPrefix = soapMessage.getSOAPPart().getEnvelope().getPrefix();
    String envNS = soapMessage.getSOAPPart().getEnvelope().getNamespaceURI(envPrefix);
    String resNS = res.lookupNamespaceURI(envPrefix);
    Assert.assertEquals(envNS, resNS);
    Assert.assertEquals("urn:foobarns", res.lookupNamespaceURI("foobarns"));
}
项目:OLD-OpenJDK8    文件:SOAPPart1_1Impl.java   
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
项目:OLD-OpenJDK8    文件:SAAJMetaFactoryImpl.java   
protected  MessageFactory newMessageFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPMessageFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
          return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPMessageFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "MessageFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating MessageFactory");
    }
}
项目:OLD-OpenJDK8    文件:SAAJMetaFactoryImpl.java   
protected  SOAPFactory newSOAPFactory(String protocol)
    throws SOAPException {
    if (SOAPConstants.SOAP_1_1_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl();
    } else if (SOAPConstants.SOAP_1_2_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.ver1_2.SOAPFactory1_2Impl();
    } else if (SOAPConstants.DYNAMIC_SOAP_PROTOCOL.equals(protocol)) {
        return new com.sun.xml.internal.messaging.saaj.soap.dynamic.SOAPFactoryDynamicImpl();
    } else {
        log.log(
            Level.SEVERE,
            "SAAJ0569.soap.unknown.protocol",
            new Object[] {protocol, "SOAPFactory"});
        throw new SOAPException("Unknown Protocol: " + protocol +
                                    "  specified for creating SOAPFactory");
    }
}