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


Java SOAPConnectionFactory.newInstance方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: findOrganizations

import javax.xml.soap.SOAPConnectionFactory; //导入方法依赖的package包/类
@Override
public List<Organization> findOrganizations() {
  try {
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection soapConnection = soapConnectionFactory.createConnection();

    try {
      SOAPMessage request = createGetKlantenRequest(username, password);
      SOAPMessage response = soapConnection.call(request, createEndPointWithTimeout(endPoint, timeout));

      return parseKlanten(response.getSOAPBody());
    } finally {
      soapConnection.close();
    }
  } catch (MalformedURLException | UnsupportedOperationException | SOAPException | XPathExpressionException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:BandwidthOnDemand,项目名称:bandwidth-on-demand,代码行数:19,代码来源:KisOnlineClient.java

示例11: SoapClient

import javax.xml.soap.SOAPConnectionFactory; //导入方法依赖的package包/类
public SoapClient(OnvifDevice device) throws Exception {
	if (device == null)
		throw new IllegalArgumentException("Device can't be null");
	this.onvifDevice = device;
	soapConnectionFactory = SOAPConnectionFactory.newInstance();
	messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
	documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
}
 
开发者ID:D2Edev,项目名称:onvifjava,代码行数:9,代码来源:SoapClient.java

示例12: searchUDDI

import javax.xml.soap.SOAPConnectionFactory; //导入方法依赖的package包/类
public static void searchUDDI(String name, String url) throws Exception {
    // Create the connection and the message factory.
    SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
    SOAPConnection connection = scf.createConnection();
    MessageFactory msgFactory = MessageFactory.newInstance();

    // Create a message
    SOAPMessage msg = msgFactory.createMessage();

    // Create an envelope in the message
    SOAPEnvelope envelope = msg.getSOAPPart().getEnvelope();

    // Get hold of the the body
    SOAPBody body = envelope.getBody();

    javax.xml.soap.SOAPBodyElement bodyElement = body.addBodyElement(envelope.createName("find_business", "",
            "urn:uddi-org:api"));

    bodyElement.addAttribute(envelope.createName("generic"), "1.0")
            .addAttribute(envelope.createName("maxRows"), "100")
            .addChildElement("name")
            .addTextNode(name);

    URLEndpoint endpoint = new URLEndpoint(url);
    msg.saveChanges();

    SOAPMessage reply = connection.call(msg, endpoint);
    //System.out.println("Received reply from: " + endpoint);
    //reply.writeTo(System.out);
    connection.close();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:UddiPing.java

示例13: getStockQuote

import javax.xml.soap.SOAPConnectionFactory; //导入方法依赖的package包/类
public String getStockQuote(String tickerSymbol) throws Exception {
    SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection con = scFactory.createConnection();

    MessageFactory factory = MessageFactory.newInstance();
    SOAPMessage message = factory.createMessage();

    SOAPPart soapPart = message.getSOAPPart();
    SOAPEnvelope envelope = soapPart.getEnvelope();

    SOAPHeader header = envelope.getHeader();
    SOAPBody body = envelope.getBody();

    header.detachNode();

    Name bodyName = envelope.createName("getQuote", "n", "urn:xmethods-delayed-quotes");
    SOAPBodyElement gltp = body.addBodyElement(bodyName);

    Name name = envelope.createName("symbol");
    SOAPElement symbol = gltp.addChildElement(name);
    symbol.addTextNode(tickerSymbol);

    URLEndpoint endpoint = new URLEndpoint("http://64.124.140.30/soap");
    SOAPMessage response = con.call(message, endpoint);
    con.close();

    SOAPPart sp = response.getSOAPPart();
    SOAPEnvelope se = sp.getEnvelope();
    SOAPBody sb = se.getBody();
    Iterator it = sb.getChildElements();
    while (it.hasNext()) {
        SOAPBodyElement bodyElement = (SOAPBodyElement) it.next();
        Iterator it2 = bodyElement.getChildElements();
        while (it2.hasNext()) {
            SOAPElement element2 = (SOAPElement) it2.next();
            return element2.getValue();
        }
    }
    return null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:41,代码来源:DelayedStockQuote.java

示例14: accept

import javax.xml.soap.SOAPConnectionFactory; //导入方法依赖的package包/类
@Override
public void accept(RadioEvents events) {
    this.events = events;
    try {
        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        soapConnection = soapConnectionFactory.createConnection();
        connected = true;
        events.connected();
    } catch (SOAPException e) {
        logger.warn("accept() failed", e);
    }
}
 
开发者ID:ChargeTimeEU,项目名称:Java-OCA-OCPP,代码行数:13,代码来源:WebServiceReceiver.java

示例15: connect

import javax.xml.soap.SOAPConnectionFactory; //导入方法依赖的package包/类
@Override
public void connect(String uri, RadioEvents events) {
    url = uri;
    this.events = events;
    try {
        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        soapConnection = soapConnectionFactory.createConnection();
        connected = true;
        events.connected();
    } catch (SOAPException e) {
        logger.warn("connect() failed", e);
    }
}
 
开发者ID:ChargeTimeEU,项目名称:Java-OCA-OCPP,代码行数:14,代码来源:WebServiceTransmitter.java


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