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


Java SOAPConnectionFactory类代码示例

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


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

示例1: registerPatients

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
public Collection<ValidationErrorMessage> registerPatients(String username, String passwordHash, String url, Collection<Subject> subjects)
        throws Exception {
    log.info("Register patients initialized by: " + username + " on: " + url);
    Collection<ValidationErrorMessage> ret = new ArrayList<>();
    for (Subject subject : subjects) {
        SOAPMessage soapMessage = requestFactory.createCreateSubject(username, passwordHash, subject);
        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection = soapConnectionFactory.createConnection();
        SOAPMessage soapResponse = soapConnection.call(soapMessage, url + "/ws/studySubject/v1");
        String error = parseRegisterSubjectsResponse(soapResponse);
        if (error != null) {
            String detailedErrorMessage = "Registering subject " + subject.getSsid() + " against instance " + url + " failed, OC error: " + error;
            log.error(detailedErrorMessage);
            ret.add(new ValidationErrorMessage(detailedErrorMessage));
        }
    }
    log.info("Registered subjects against instance " + url + " completed, number of subjects:" +
                subjects.size());
    return ret;

}
 
开发者ID:thehyve,项目名称:Open-Clinica-Data-Uploader,代码行数:22,代码来源:OpenClinicaService.java

示例2: testSendReceiveMessageWithEmptyNSPrefix

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
@Validated @Test
public void testSendReceiveMessageWithEmptyNSPrefix() throws Exception {
    MessageFactory mf = MessageFactory.newInstance();
    SOAPMessage request = mf.createMessage();

    SOAPPart sPart = request.getSOAPPart();
    SOAPEnvelope env = sPart.getEnvelope();
    SOAPBody body = env.getBody();

    //Namespace prefix is empty
    body.addBodyElement(new QName("http://fakeNamespace2.org","echo"))
    							.addTextNode("This is some text");

    SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage response = sCon.call(request, getAddress());
    assertFalse(response.getAttachments().hasNext());
    assertEquals(0, response.countAttachments());

    String requestStr = printSOAPMessage(request);
    String responseStr = printSOAPMessage(response);
    assertTrue(responseStr.indexOf("echo") > -1);
    sCon.close();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:IntegrationTest.java

示例3: invoke

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
/**
 *  Marshals the inout arguments into a SOAPMessage
 * and invokes the WebService.
 * @param arguments the arguments for the WebService.
 * @return the reply from the WebService.
 * @throws SOAPException if any SOAP error occurs.
 * @throws SOAPFaultException if any SOAPFault occurs.
 * @throws JAXBException if any XML (un)marshalling error occurs.
 */
public Object invoke(Object... arguments) throws SOAPException, SOAPFaultException, JAXBException {
    SOAPConnection connection = null;

    try {
        // Create a connection
        connection = SOAPConnectionFactory.newInstance().createConnection();

        // Create the SOAPMessage
        SOAPMessage message = createSOAPMessage(arguments);

        // Invoke the WebService
        SOAPMessage response = invoke(connection, message);

        // Unmarshal the response
        return unmarshalResponse(response);
    } finally {
        // Always close the connection
        if (connection != null) {
            connection.close();
        }
    }
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:32,代码来源:WebServiceInvoker.java

示例4: sendSoapMessage

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
/**
 * sendSoapMessage Connect to the service, will log the request and response
 *
 * @param webServiceKey
 *            the key to locate which web service to use
 * @param request
 *            - SoapMessage to send to the service
 * @return - SoapMessage response
 * @throws MalformedURLException
 *             - if there was an error creating the endpoint Connection
 * @throws SOAPException
 *             - if there was an error creating the SOAP Connection
 */
public SOAPMessage sendSoapMessage(String webServiceKey, SOAPMessage request) throws MalformedURLException, SOAPException {
    SOAPMessage response = null;

    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection connection = soapConnectionFactory.createConnection();
    try {

        WebService service = getWebService(webServiceKey);

        logSOAPMessage(request, "SOAP Request");

        URL endpoint = new URL(service.getEndPoint());

        response = connection.call(request, endpoint);

        logSOAPMessage(response, "SOAP Response");
    } catch (Exception e) {
        throw e;
    } finally {
        connection.close();
    }

    return response;
}
 
开发者ID:AgileTestingFramework,项目名称:atf-toolbox-java,代码行数:38,代码来源:WebServiceAutomationManager.java

示例5: sendReceive

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
public SOAPMessage sendReceive(SOAPMessage msg, String URLAddress)
	throws SOAPException, MalformedURLException{
    
    
 	setProxyFromINI(true);
 	URL endPoint = new URL(URLAddress);
    SOAPMessage reply=null; 
    // TODO: set proxy ako treba
    SOAPConnectionFactory factory = SOAPConnectionFactory.newInstance();
   
    SOAPConnection con = factory.createConnection();
    if(con==null){
    	if(MessagingEnvironment.DEBUG==1)
    		System.out.println("SOAPConnection failure!");
    }else{
      
    	reply = con.call(msg, endPoint);
       	con.close();
       	if(MessagingEnvironment.DEBUG==1)
       		System.out.println("\nSending to: "+URLAddress+" success");
    }
    setProxyFromINI(false);
    return reply;
}
 
开发者ID:unsftn,项目名称:bisis-v4,代码行数:25,代码来源:SOAPUtilClient.java

示例6: testSoapConnectionGet

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
@Test
@RunAsClient
public void testSoapConnectionGet() throws Exception
{
   final String serviceURL = baseURL + "/greetMe";
   SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();

   SOAPConnection con = conFac.createConnection();
   URL endpoint = new URL(serviceURL);
   MessageFactory msgFactory = MessageFactory.newInstance();
   SOAPMessage msg = msgFactory.createMessage();
   msg.getSOAPBody().addBodyElement(new QName("http://www.jboss.org/jbossws/saaj", "greetMe"));
   SOAPMessage response = con.call(msg, endpoint);
   QName greetMeResp = new QName("http://www.jboss.org/jbossws/saaj", "greetMeResponse");

   Iterator<?> sayHiRespIterator = response.getSOAPBody().getChildElements(greetMeResp);
   SOAPElement soapElement = (SOAPElement) sayHiRespIterator.next();
   assertNotNull(soapElement);

   assertEquals(1, response.countAttachments());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:22,代码来源:JBWS3084CxfTestCase.java

示例7: testSOAP12SoapFaultExceptionOnHTTP400UsingSAAJ

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
@Test
@RunAsClient
public void testSOAP12SoapFaultExceptionOnHTTP400UsingSAAJ() throws Exception
{
   try
   {
      //<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><ns2:throwSoapFaultException xmlns:ns2="http://server.exception.samples.jaxws.ws.test.jboss.org/"/></soap:Body></soap:Envelope>
      
      SOAPConnectionFactory conFac = SOAPConnectionFactory.newInstance();

      SOAPConnection con = conFac.createConnection();
      MessageFactory msgFactory = MessageFactory.newInstance();
      SOAPMessage msg = msgFactory.createMessage();
      msg.getSOAPBody().addBodyElement(new QName(targetNS, "throwSoapFaultException"));
      SOAPMessage response = con.call(msg, new URL(targetEndpoint + "Servlet"));
      Element el = (Element)response.getSOAPBody().getChildElements().next();
      assertEquals("Fault", el.getLocalName());
   }
   catch (Exception e)
   {
      fail(e);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:24,代码来源:JBWS3945TestCase.java

示例8: testProviderMessage

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
@Test
@RunAsClient
public void testProviderMessage() throws Exception
{
   SOAPMessage reqMsg = getRequestMessage();
   SOAPEnvelope reqEnv = reqMsg.getSOAPPart().getEnvelope();

   URL epURL = baseURL;
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   SOAPEnvelope resEnv = resMsg.getSOAPPart().getEnvelope();

   SOAPHeader soapHeader = resEnv.getHeader();
   if (soapHeader != null)
      soapHeader.detachNode();
   
   assertEquals(reqEnv, resEnv);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:19,代码来源:ProviderMessageTestCase.java

示例9: testProviderMessageNullResponse

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
@Test
@RunAsClient
public void testProviderMessageNullResponse() throws Exception
{
   MessageFactory msgFactory = MessageFactory.newInstance();
   SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(msgStringForNullResponse.getBytes()));

   URL epURL = baseURL;
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   if (resMsg != null)
   {
      SOAPPart soapPart = resMsg.getSOAPPart();
      //verify there's either nothing in the reply or at least the response body is empty
      if (soapPart != null && soapPart.getEnvelope() != null && soapPart.getEnvelope().getBody() != null)
      {
         SOAPBody soapBody = soapPart.getEnvelope().getBody();
         assertFalse(soapBody.getChildElements().hasNext());
      }
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:22,代码来源:ProviderMessageTestCase.java

示例10: testLegalMessageAccess

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
@Test
@RunAsClient
public void testLegalMessageAccess() throws Exception
{
   MessageFactory msgFactory = MessageFactory.newInstance();
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();

   String reqEnv =
      "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
      " <env:Header/>" +
      " <env:Body>" +
      "  <ns1:echoString xmlns:ns1='" + targetNS + "'>" +
      "   <arg0>Hello</arg0>" +
      "  </ns1:echoString>" +
      " </env:Body>" +
      "</env:Envelope>";
   SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));

   URL epURL = new URL(baseURL + "/TestService");
   SOAPMessage resMsg = con.call(reqMsg, epURL);

   QName qname = new QName(targetNS, "echoStringResponse");
   SOAPElement soapElement = (SOAPElement)resMsg.getSOAPBody().getChildElements(qname).next();
   soapElement = (SOAPElement)soapElement.getChildElements(new QName("return")).next();
   assertEquals("Hello", soapElement.getValue());
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:27,代码来源:WebMethodTestCase.java

示例11: testIllegalMessageAccess

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
@Test
@RunAsClient
public void testIllegalMessageAccess() throws Exception
{
   MessageFactory msgFactory = MessageFactory.newInstance();
   SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();

   String reqEnv =
      "<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
      " <env:Header/>" +
      " <env:Body>" +
      "  <ns1:noWebMethod xmlns:ns1='" + targetNS + "'>" +
      "   <String_1>Hello</String_1>" +
      "  </ns1:noWebMethod>" +
      " </env:Body>" +
      "</env:Envelope>";
   SOAPMessage reqMsg = msgFactory.createMessage(null, new ByteArrayInputStream(reqEnv.getBytes()));

   URL epURL = new URL(baseURL + "/TestService");
   SOAPMessage resMsg = con.call(reqMsg, epURL);
   SOAPFault soapFault = resMsg.getSOAPBody().getFault();
   assertNotNull("Expected SOAPFault", soapFault);

   String faultString = soapFault.getFaultString();
   assertTrue(faultString, faultString.indexOf("noWebMethod") > 0);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:27,代码来源:WebMethodTestCase.java

示例12: testSendMultipartSoapMessage

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
@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);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:22,代码来源:MultipartContentTypeTestCase.java

示例13: sendMessage

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
public SOAPMessage sendMessage() throws Exception {
    SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();

    SOAPConnection connection = conFactory.createConnection();
    MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage msg = msgFactory.createMessage();
    SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-attachment:1.0", "echoImage"));
    bodyElement.addTextNode("cid:switchyard.png");

    // CXF does not set content-type.
    msg.getMimeHeaders().addHeader("Content-Type", "multipart/related; type=\"text/xml\"; start=\"<[email protected]>\"");
    msg.getSOAPPart().setContentId("<[email protected]>");

    AttachmentPart ap = msg.createAttachmentPart();
    ap.setDataHandler(new DataHandler(new StreamDataSource()));
    ap.setContentId("<switchyard.png>");
    msg.addAttachmentPart(ap);

    return connection.call(msg, new URL(SWITCHYARD_WEB_SERVICE));
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:21,代码来源:SoapAttachmentQuickstartTest.java

示例14: sendMessage

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
public SOAPMessage sendMessage() throws Exception {
    SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();

    SOAPConnection connection = conFactory.createConnection();
    MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage msg = msgFactory.createMessage();
    SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-attachment:1.0", "echoImage"));
    bodyElement.addTextNode("cid:switchyard.png");

    msg.getSOAPPart().setContentId("<[email protected]>");

    AttachmentPart ap = msg.createAttachmentPart();
    ap.setDataHandler(new DataHandler(new StreamDataSource()));
    ap.setContentId("<switchyard.png>");
    msg.addAttachmentPart(ap);
    msg.saveChanges();

    // SWITCHYARD-2818/CXF-6665 - CXF does not set content-type properly.
    String contentType = msg.getMimeHeaders().getHeader("Content-Type")[0];
    contentType += "; start=\"<[email protected]>\"; start-info=\"application/soap+xml\"; action=\"urn:switchyard-quickstart:soap-attachment:1.0:echoImage\"";
    msg.getMimeHeaders().setHeader("Content-Type", contentType);

    return connection.call(msg, new URL(SWITCHYARD_WEB_SERVICE));
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:25,代码来源:SoapAttachmentQuickstartTest.java

示例15: sendMessage

import javax.xml.soap.SOAPConnectionFactory; //导入依赖的package包/类
public static SOAPMessage sendMessage(String switchyard_web_service) throws Exception {
    SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();

    SOAPConnection connection = conFactory.createConnection();
    MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SOAPMessage msg = msgFactory.createMessage();
    SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-attachment:1.0", "echoImage"));
    bodyElement.addTextNode("cid:switchyard.png");

    AttachmentPart ap = msg.createAttachmentPart();
    URL imageUrl = Classes.getResource("switchyard.png");
    ap.setDataHandler(new DataHandler(new URLDataSource(imageUrl)));
    ap.setContentId("switchyard.png");
    msg.addAttachmentPart(ap);
    msg.saveChanges();

    // SWITCHYARD-2818/CXF-6665 - CXF does not set content-type properly.
    String contentType = msg.getMimeHeaders().getHeader("Content-Type")[0];
    contentType += "; start=\"<[email protected]>\"; start-info=\"application/soap+xml\"; action=\"urn:switchyard-quickstart:soap-attachment:1.0:echoImage\"";
    msg.getMimeHeaders().setHeader("Content-Type", contentType);

    return connection.call(msg, new URL(switchyard_web_service));
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:24,代码来源:SoapAttachmentClient.java


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