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


Java SOAPConnection.close方法代码示例

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


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

示例1: processRequest

import javax.xml.soap.SOAPConnection; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
// blocking
public <T> T processRequest(Object request, Class<T> responseClass, String soapUri, boolean needsAuthentification)
		throws Exception {
	SOAPConnection soapConnection = null;
	try {
		soapConnection = soapConnectionFactory.createConnection();
		SOAPMessage soapMessage = processSoapMessage(request, needsAuthentification);
		SOAPMessage soapResponse = soapConnection.call(soapMessage, soapUri);
		// get new each time? - no
		Unmarshaller unmarshaller = getUnmarshaller(responseClass);
		return (T) unmarshaller.unmarshal(soapResponse.getSOAPBody().extractContentAsDocument());
	} finally {
		if (soapConnection != null) {
			soapConnection.close();
		}
	}

}
 
开发者ID:D2Edev,项目名称:onvifjava,代码行数:21,代码来源:SoapClient.java

示例2: testSendReceiveMessageWithEmptyNSPrefix

import javax.xml.soap.SOAPConnection; //导入方法依赖的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.SOAPConnection; //导入方法依赖的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.SOAPConnection; //导入方法依赖的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.SOAPConnection; //导入方法依赖的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: testSendReceiveSimpleSOAPMessage

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

    createSimpleSOAPPart(request);

    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,代码行数:18,代码来源:IntegrationTest.java

示例7: testSendReceive_ISO88591_EncodedSOAPMessage

import javax.xml.soap.SOAPConnection; //导入方法依赖的package包/类
@Validated @Test
public void testSendReceive_ISO88591_EncodedSOAPMessage() throws Exception {
	MimeHeaders mimeHeaders = new MimeHeaders();
    mimeHeaders.addHeader("Content-Type", "text/xml; charset=iso-8859-1");
    
    InputStream inputStream = TestUtils.getTestFile("soap-part-iso-8859-1.xml");
    SOAPMessage requestMessage = MessageFactory.newInstance().createMessage(mimeHeaders, inputStream);
    

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

    printSOAPMessage(requestMessage);
    String responseStr = printSOAPMessage(response);
    assertEquals("This is some text.Here are some special chars : \u00F6\u00C6\u00DA\u00AE\u00A4",
                 response.getSOAPBody().getElementsByTagName("something").item(0).getTextContent());
    assertTrue(responseStr.indexOf("echo") != -1);
    sCon.close();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:IntegrationTest.java

示例8: testCallWithSOAPAction

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

    String soapAction = "urn:test:echo";
    
    request.getSOAPPart().getEnvelope().getBody().addBodyElement(new QName("urn:test", "echo"));
    request.getMimeHeaders().addHeader("SOAPAction", soapAction);

    SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
    sCon.call(request, getAddress());
    sCon.close();
    
    assertEquals(soapAction, lastSoapAction);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:17,代码来源:IntegrationTest.java

示例9: testCallMTOM

import javax.xml.soap.SOAPConnection; //导入方法依赖的package包/类
@Validated @Test
public void testCallMTOM() throws Exception {
    MessageFactory mf = MessageFactory.newInstance();
    
    MimeHeaders headers = new MimeHeaders();
    headers.addHeader("Content-Type", TestUtils.MTOM_TEST_MESSAGE_CONTENT_TYPE);
    InputStream in = TestUtils.getTestFile(TestUtils.MTOM_TEST_MESSAGE_FILE);
    SOAPMessage request = mf.createMessage(headers, in);
    SOAPEnvelope envelope = request.getSOAPPart().getEnvelope();
    
    // Remove the headers since they have mustunderstand=1 
    envelope.getHeader().removeContents();
    // Change the name of the body content so that the request is routed to the echo service
    ((SOAPElement)envelope.getBody().getChildElements().next()).setElementQName(new QName("echo"));
    
    SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
    SOAPMessage response = sCon.call(request, getAddress());
    sCon.close();
    
    SOAPPart soapPart = response.getSOAPPart();
    SOAPElement textElement =
            (SOAPElement)soapPart.getEnvelope().getElementsByTagName("text").item(0);
    AttachmentPart ap = response.getAttachment((SOAPElement)textElement.getChildNodes().item(0));
    assertNotNull(ap);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:26,代码来源:IntegrationTest.java

示例10: findOrganizations

import javax.xml.soap.SOAPConnection; //导入方法依赖的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: searchUDDI

import javax.xml.soap.SOAPConnection; //导入方法依赖的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

示例12: getStockQuote

import javax.xml.soap.SOAPConnection; //导入方法依赖的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

示例13: sendJaxmMsg

import javax.xml.soap.SOAPConnection; //导入方法依赖的package包/类
private void sendJaxmMsg (String aMsg, String u)  {
	try	{
		System.setProperty("javax.net.ssl.trustStore", u);

		SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
		SOAPConnection connection = scf.createConnection();

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

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

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

		SOAPHeaderElement headerElement = header.addHeaderElement(envelope.createName("OSCAR", "DT", "http://www.oscarhome.org/"));
	    headerElement.addTextNode("header");

		SOAPBodyElement bodyElement = body.addBodyElement(envelope.createName("Service"));
	    bodyElement.addTextNode("compete");

		AttachmentPart ap1 = message.createAttachmentPart();
		ap1.setContent(aMsg, "text/plain");

		message.addAttachmentPart(ap1);

		URLEndpoint endPoint = new URLEndpoint (URLService);  //"https://67.69.12.115:8443/OscarComm/DummyReceiver");
		SOAPMessage reply = connection.call(message, endPoint);

		connection.close();
	} catch (Exception e)	{
		MiscUtils.getLogger().error("Error", e);
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:36,代码来源:FrmStudyXMLClientSend.java

示例14: executeApiCallWith

import javax.xml.soap.SOAPConnection; //导入方法依赖的package包/类
private SOAPMessage executeApiCallWith(SOAPMessage soapMessage) throws SOAPException {
    SOAPConnection connection = null;
    try {
        connection = soapConnectionFactory.createConnection();
        return connection.call(soapMessage, WRAPPER_API_ENDPOINT);
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:hill-daniel,项目名称:soap-wrapper-lambda,代码行数:16,代码来源:WrapperApiEndpointIntegrationTest.java

示例15: listStudies

import javax.xml.soap.SOAPConnection; //导入方法依赖的package包/类
public List<Study> listStudies(String username, String passwordHash, String url) throws Exception { //TODO: handle exceptions
    log.info("List studies initiated by: " + username + " on: " + url);
    SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
    SOAPConnection soapConnection = soapConnectionFactory.createConnection();
    SOAPMessage message = requestFactory.createListStudiesRequest(username, passwordHash);
    SOAPMessage soapResponse = soapConnection.call(message, url + "/ws/study/v1");  // Add SOAP endopint to OCWS URL.
    List<Study> studies = ListStudiesResponseHandler.parseListStudiesResponse(soapResponse);
    soapConnection.close();
    return studies;
}
 
开发者ID:thehyve,项目名称:Open-Clinica-Data-Uploader,代码行数:11,代码来源:OpenClinicaService.java


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