本文整理汇总了Java中javax.xml.soap.SOAPConnectionFactory.createConnection方法的典型用法代码示例。如果您正苦于以下问题:Java SOAPConnectionFactory.createConnection方法的具体用法?Java SOAPConnectionFactory.createConnection怎么用?Java SOAPConnectionFactory.createConnection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.soap.SOAPConnectionFactory
的用法示例。
在下文中一共展示了SOAPConnectionFactory.createConnection方法的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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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());
}
示例5: 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);
}
}
示例6: 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);
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
}
示例11: 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();
}
示例12: 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;
}
示例13: echoUsingSAAJ
import javax.xml.soap.SOAPConnectionFactory; //导入方法依赖的package包/类
/**
* This method sends a file as an attachment then
* receives it as a return. The returned file is
* compared to the source. Uses SAAJ API.
* @param The filename that is the source to send.
* @return True if sent and compared.
*/
public boolean echoUsingSAAJ(String filename) throws Exception {
String endPointURLString = "http://localhost:" +opts.getPort() + "/axis/services/urn:EchoAttachmentsService";
SOAPConnectionFactory soapConnectionFactory =
javax.xml.soap.SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection =
soapConnectionFactory.createConnection();
MessageFactory messageFactory =
MessageFactory.newInstance();
SOAPMessage soapMessage =
messageFactory.createMessage();
SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope requestEnvelope =
soapPart.getEnvelope();
SOAPBody body = requestEnvelope.getBody();
SOAPBodyElement operation = body.addBodyElement
(requestEnvelope.createName("echo"));
Vector dataHandlersToAdd = new Vector();
dataHandlersToAdd.add(new DataHandler(new FileDataSource(new
File(filename))));
if (dataHandlersToAdd != null) {
ListIterator dataHandlerIterator =
dataHandlersToAdd.listIterator();
while (dataHandlerIterator.hasNext()) {
DataHandler dataHandler = (DataHandler)
dataHandlerIterator.next();
javax.xml.soap.SOAPElement element =
operation.addChildElement(requestEnvelope.createName("source"));
javax.xml.soap.AttachmentPart attachment =
soapMessage.createAttachmentPart(dataHandler);
soapMessage.addAttachmentPart(attachment);
element.addAttribute(requestEnvelope.createName
("href"), "cid:" + attachment.getContentId());
}
}
javax.xml.soap.SOAPMessage returnedSOAPMessage =
soapConnection.call(soapMessage, endPointURLString);
Iterator iterator = returnedSOAPMessage.getAttachments();
if (!iterator.hasNext()) {
//The wrong type of object that what was expected.
System.out.println("Received problem response from server");
throw new AxisFault("", "Received problem response from server", null, null);
}
//Still here, so far so good.
//Now lets brute force compare the source attachment
// to the one we received.
DataHandler rdh = (DataHandler) ((AttachmentPart)iterator.next()).getDataHandler();
//From here we'll just treat the data resource as file.
String receivedfileName = rdh.getName();//Get the filename.
if (receivedfileName == null) {
System.err.println("Could not get the file name.");
throw new AxisFault("", "Could not get the file name.", null, null);
}
System.out.println("Going to compare the files..");
boolean retv = compareFiles(filename, receivedfileName);
java.io.File receivedFile = new java.io.File(receivedfileName);
receivedFile.delete();
return retv;
}
示例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);
}
}
示例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);
}
}