Java Soapconnectionfactory 12 Example
Best Java code snippets using javax.xml.soap.SOAPConnectionFactory (Showing top 20 results out of 315)
Refine search
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory. newInstance (); SOAPConnection soapConnection = soapConnectionFactory. createConnection (); SOAPMessage soapResponse = soapConnection. call (createSOAPRequest(), url); soapResponse. writeTo (System.out); soapConnection. close (); MessageFactory messageFactory = MessageFactory. newInstance (); SOAPMessage soapMessage = messageFactory. createMessage (); SOAPPart soapPart = soapMessage. getSOAPPart (); SOAPEnvelope envelope = soapPart. getEnvelope (); envelope. addNamespaceDeclaration ( "example" , serverURI); SOAPBody soapBody = envelope. getBody (); SOAPElement soapBodyElem = soapBody. addChildElement ( "VerifyEmail" , "example" ); SOAPElement soapBodyElem1 = soapBodyElem. addChildElement ( "email" , "example" ); soapBodyElem1. addTextNode ( "mutantninja@gmail.com" ); SOAPElement soapBodyElem2 = soapBodyElem. addChildElement ( "LicenseKey" , "example" ); soapBodyElem2. addTextNode ( "123" ); MimeHeaders headers = soapMessage. getMimeHeaders (); headers.addHeader( "SOAPAction" , serverURI + "VerifyEmail" );
try { SOAPMessage reqMsg = MessageFactory. newInstance (). createMessage (); SOAPEnvelope envelope = reqMsg. getSOAPPart (). getEnvelope (); SOAPBody body = envelope. getBody (); SOAPBodyElement service = body.addBodyElement(envelope. createName ( "HostConnect" , "" , WCFNameSpace)); SOAPElement paramInMsg = service. addChildElement (envelope. createName ( "inMsg" , "" , "" )); SOAPElement paramBodySection = paramInMsg. addChildElement (envelope. createName ( "BodySection" , "" , DataContractNameSpace)); SOAPElement paramTextSection = paramInMsg. addChildElement (envelope. createName ( "TextSection" , "" , DataContractNameSpace)); MimeHeaders headers = reqMsg. getMimeHeaders (); headers.addHeader( "SOAPAction" , SoapAction); headers.setHeader( "Content-Type" , "text/xml; charset=utf-8" ); SOAPConnection con = SOAPConnectionFactory. newInstance (). createConnection (); SOAPMessage resMsg = con. call (reqMsg, URL); resMsg. saveChanges (); con. close ();
SOAPMessage message = MessageFactory. newInstance (). createMessage (); SOAPHeader header = message. getSOAPHeader (); header.detachNode(); SOAPEnvelope envelope = message. getSOAPPart (). getEnvelope (); envelope.setAttribute( "namespace" , "namespaceUrl" ); SOAPBody body = message. getSOAPBody (); QName bodyName = new QName( "getResponse" ); SOAPBodyElement bodyElement = body.addBodyElement(bodyName); SOAPElement symbol = bodyElement. addChildElement ( "name" ); symbol. addTextNode ( "Harry Joy" ); SOAPConnection connection = SOAPConnectionFactory. newInstance (). createConnection (); SOAPMessage response = connection. call (message, endpoint); connection.close SOAPBody responseBody = response. getSOAPBody (); SOAPBodyElement responseElement = (SOAPBodyElement)responseBody.getChildElements().next(); SOAPElement returnElement = (SOAPElement)responseElement. getChildElements ().next(); if (responseBody.getFault()!=null){ System.out.println(returnElement.getValue()+ " " +responseBody.getFault().getFaultString());
MessageFactory factory = MessageFactory. newInstance (); SOAPMessage message = factory. createMessage (); SOAPPart soapPart = message. getSOAPPart (); SOAPEnvelope envelope = soapPart. getEnvelope (); SOAPHeader header = envelope. getHeader (); SOAPBody body = envelope. getBody (); Name attributeName = envelope. createName ( "xmlsn" ); bodyElement. addAttribute (attributeName, "http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" ); SOAPElement MM7Version = bodyElement. addChildElement (bodyName); MM7Version.setTextContent(MM7_VERSION); SOAPElement SenderIdentification = bodyElement. addChildElement (bodyName); message. addAttachmentPart (attachment1); SOAPConnectionFactory. newInstance (); soapConnectionFactory. createConnection (); SOAPMessage response = connection. call (message, endpoint); System.out.println(); connection. close ();
SOAPConnection soapConnection = soapConnectionFactory. createConnection (); SOAPMessage soapResponse = soapConnection. call (createSOAPRequest(), url); soapResponse. writeTo (System.out); soapConnection. close (); } catch (Exception e) { System.err.println( "Error occurred while sending SOAP Request to Server" ); SOAPMessage soapMessage = messageFactory. createMessage (); SOAPPart soapPart = soapMessage. getSOAPPart (); SOAPEnvelope envelope = soapPart. getEnvelope (); envelope. addNamespaceDeclaration ( "soap" , serverURI); SOAPBody soapBody = envelope. getBody (); SOAPElement soapBodyElem = soapBody.addChildElement( "PessoaFisicaSimplificada" , "" , "SOAWebServices" ); SOAPElement soapBodyElemC = soapBodyElem. addChildElement ( "Credenciais" ); SOAPElement soapBodyElem1 = soapBodyElemC. addChildElement ( "Email" ); soapBodyElem1. addTextNode ( "EMAIL" ); SOAPElement soapBodyElem2 = soapBodyElemC. addChildElement ( "Senha" ); soapBodyElem2. addTextNode ( "PASSWORD" ); SOAPElement soapBodyElem4 = soapBodyElem. addChildElement ( "DataNascimento" ); soapBodyElem4. addTextNode ( "Date" ); MimeHeaders headers = soapMessage. getMimeHeaders (); headers.addHeader( "SOAPAction" , serverURI);
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); this .soapConnection = soapConnectionFactory. createConnection (); MessageFactory messageFactory = MessageFactory.newInstance(); SOAPMessage soapMessage = messageFactory. createMessage (); SOAPPart soapPart = soapMessage. getSOAPPart (); SOAPEnvelope envelope = soapPart. getEnvelope (); envelope. addNamespaceDeclaration ( "ser" , "http://server.splat/" ); SOAPBody soapBody = envelope. getBody (); SOAPElement soapBodyElem = soapBody.addChildElement(operation, "ser" ); int n = 0 ; for (Object argN : args) { SOAPElement soapBodyElemN = soapBodyElem. addChildElement ( "arg" + n++); soapBodyElemN. addTextNode (argN.toString()); } MimeHeaders headers = soapMessage. getMimeHeaders (); headers.addHeader( "SOAPAction" , "\"\"" ); soapMessage. saveChanges (); debug(operation + " Request SOAP Message:\n" + traceSOAPMessage(soapMessage)); SOAPMessage soapResponse = this .soapConnection.call( soapMessage, this .url );
SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); SOAPConnection connection = sfc. createConnection (); SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); SOAPPart soapPart = soapMessage. getSOAPPart (); SOAPEnvelope soapEnvelope = soapPart. getEnvelope (); SOAPBody soapBody = soapEnvelope. getBody (); SOAPElement Header = soapBody.addBodyElement( new QName( "Header" )); SOAPElement Security= Header. addChildElement ( new QName( "Security" )); SOAPElement UsernameToken= Security. addChildElement ( new QName( "UsernameToken" )); SOAPElement Username= UsernameToken. addChildElement ( new QName( "Username" )); SOAPElement Password= UsernameToken. addChildElement ( new QName( "Password" )); Username. addTextNode ( "username" ); Password. addTextNode ( "password" ); URL endpoint = "http://localhost:8080/soap/getMessage?wsdl" ; SOAPMessage response = connection. call (soapMessage, endpoint);
SOAPConnection soapConnection = soapConnectionFactory. createConnection (); SOAPMessage soapResponse = soapConnection. call (createSOAPRequest(), url); soapResponse. writeTo (System.out); soapConnection. close (); SOAPMessage soapMessage = messageFactory. createMessage (); SOAPPart soapPart = soapMessage. getSOAPPart (); SOAPEnvelope envelope = soapPart. getEnvelope (); SOAPHeader header = envelope. getHeader (); SOAPBody body = envelope. getBody (); SOAPBodyElement element = body.addBodyElement(envelope. createName ( "echoTest" , "" , serverURI)); element.addChildElement( "echoString" ).addTextNode( "Hello!!!" );
SOAPConnection conn = scf. createConnection (); MessageFactory mf = MessageFactory.newInstance(); SOAPMessage msg = mf. createMessage (); SOAPPart sp = msg. getSOAPPart (); SOAPEnvelope env = sp. getEnvelope (); env. addNamespaceDeclaration ( "tns" , "http://www.otrs.org/TicketConnector/" ); SOAPBody body = env. getBody (); SOAPBodyElement dispatch = body.addBodyElement( new QName( "http://www.otrs.org/TicketConnector/" , "TicketCreate" , "tns" )); dispatch.addChildElement( new QName( "http://www.otrs.org/TicketConnector/" , "UserLogin" , "tns" )).addTextNode( "some user login" ); tkt. addChildElement ( new QName( "http://www.otrs.org/TicketConnector/" , "Title" , "tns" )).addTextNode( "some title" ); tkt. addChildElement ( new QName( "http://www.otrs.org/TicketConnector/" , "Queue" , "tns" )).addTextNode( "one of your queue names" ); tkt. addChildElement ( new QName( "http://www.otrs.org/TicketConnector/" , "Type" , "tns" )).addTextNode( "one of your types" ); tkt. addChildElement ( new QName( "http://www.otrs.org/TicketConnector/" , "CustomerUser" , "tns" )).addTextNode( "some email address not customer id/name/username. Thought this could be my sys config" ); tkt. addChildElement ( new QName( "http://www.otrs.org/TicketConnector/" , "State" , "tns" )).addTextNode( "one of your states" ); msg. writeTo (System.out); System.out.println(); URL url = new URL( "http://your otrs ip address/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorSOAP" ); SOAPMessage resp = conn. call (msg, url); resp. writeTo (System.out); System.out.println(); } catch (SOAPException | UnsupportedOperationException | IOException e) {
SOAPConnection connection = soapConnectionFactory. createConnection (); SOAPFactory soapFactory = SOAPFactory.newInstance(); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory. createMessage (); SOAPHeader header = message. getSOAPHeader (); SOAPBody body = message. getSOAPBody (); header.detachNode(); symbol. addTextNode ( "10" ); name = envelope.createName( "number2" ); symbol = bodyElement.addChildElement(name); symbol. addTextNode ( "20" ); message. writeTo (System.out); System.out.println(); SOAPMessage response = connection. call (message, endpoint); System.out.println( "Answer is: " + resp); connection. close ();
SOAPConnection soapConnection = soapConnectionFactory. createConnection (); SOAPMessage soapMessage = messageFactory. createMessage (); soapMessage. getMimeHeaders ().addHeader( "Authorization" , "Basic " + encodedString); soapMessage. getMimeHeaders ().addHeader( "SOAPAction" , "https://api.ewaypayments.com/CreateAccessCode" ); SOAPPart soapPart = soapMessage. getSOAPPart (); SOAPEnvelope soapEnvelope = soapPart. getEnvelope (); SOAPBody soapBody = soapEnvelope. getBody (); soapBody.addDocument(doc); soapMessage. saveChanges (); SOAPMessage reply = soapConnection. call (soapMessage, "https://api.sandbox.ewaypayments.com/Soap.asmx" );
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. getMimeHeaders ().addHeader( "Content-Type" , "multipart/related; type=\"text/xml\"; start=\"<root.message@cxf.apache.org>\"" ); msg. getSOAPPart (). setContentId ( "<root.message@cxf.apache.org>" ); 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)); }
SOAPConnectionFactory soapfactory=SOAPConnectionFactory.newInstance(); SOAPConnection soapconnection=soapfactory. createConnection (); MessageFactory messagefactory=MessageFactory.newInstance(); SOAPMessage messege=messagefactory. createMessage (); SOAPEnvelope envelop=messege. getSOAPPart ().getEnvelope(); SOAPHeader header=messege. getSOAPHeader (); SOAPBody body=messege. getSOAPBody (); Name header_context=envelop. createName ( "context" , null, "urn:zimbra" ); Name auth_request=envelop. createName ( "AuthRequest" ,null, "urn:zimbraAccount" ); Name account=envelop. createName ( "account" ); Name password=envelop. createName ( "password" ); header.addHeaderElement(header_context); SOAPBodyElement auth_body=body.addBodyElement(auth_request); auth_body.addChildElement(account).addAttribute(envelop. createName ( "by" ), "name" ).addTextNode( "abc" ); auth_body.addChildElement(password).addTextNode( "1234" ); URL url= new URL( "http://192.168.1.67/service/soap/AuthRequest" ); SOAPMessage response=soapconnection. call (messege, url);
public SOAPMessage execute(String endpointUrl, SOAPMessage message) throws SOAPException, IOException { SOAPConnection conn = null; try { conn = SOAPConnectionFactory. newInstance (). createConnection (); SOAPMessage response = conn. call (message, endpointUrl); SOAPBody body = response. getSOAPBody (); if (body.hasFault()) throw new SOAPException(body.getFault().getFaultString()); return response; } finally { if (conn != null) conn. close (); } }
@Test public void testSWA() throws Exception { SOAPFactory soapFac = SOAPFactory.newInstance(); MessageFactory msgFac = MessageFactory. newInstance (); SOAPConnectionFactory conFac = SOAPConnectionFactory. newInstance (); SOAPMessage msg = msgFac. createMessage (); QName sayHi = new QName( "http://apache.org/hello_world_rpclit" , "sayHiWAttach" ); msg. getSOAPBody ().addChildElement(soapFac.createElement(sayHi)); AttachmentPart ap1 = msg. createAttachmentPart (); ap1.setContent( "Attachment content" , "text/plain" ); msg. addAttachmentPart (ap1); AttachmentPart ap2 = msg. createAttachmentPart (); ap2.setContent( "Attachment content - Part 2" , "text/plain" ); msg. addAttachmentPart (ap2); msg. saveChanges (); SOAPConnection con = conFac. createConnection (); URL endpoint = new URL( "http://localhost:" + PORT + "/SOAPServiceProviderRPCLit/SoapPortProviderRPCLit1" ); SOAPMessage response = con. call (msg, endpoint); QName sayHiResp = new QName( "http://apache.org/hello_world_rpclit" , "sayHiResponse" ); assertNotNull(response. getSOAPBody ().getChildElements(sayHiResp)); assertEquals( 2 , response. countAttachments ()); }
protected void forwardMessage(SOAPMessageContext ctx, EndpointReference ref) { try { SOAPConnection soapConn = SOAPConnectionFactory. newInstance (). createConnection (); soapConn. call (ctx.getMessage(), new URL(ref.getAddress().toString())); soapConn. close (); SOAPBody responseBody = ctx.getMessage(). getSOAPPart (). getEnvelope (). getBody (); removeAllChildElements(responseBody); } catch (SOAPException e) { throw new JAXRPCException( "Failed to forward SOAP message." , e); } catch (MalformedURLException e) { throw new JAXRPCException( "Failed to forward SOAP message." , e); } }
import javax.xml.soap.*; public String callTestService(String soapRequestXml, String url) throws Exception { SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory. newInstance (); SOAPConnection soapConnection = soapConnectionFactory. createConnection (); SOAPMessage soapRequest = MessageFactory. newInstance (). createMessage ( new MimeHeaders(), new ByteArrayInputStream(soapRequestXml.getBytes())); SOAPMessage soapResponse = soapConnection. call (soapRequest, url); ByteArrayOutputStream soapResponseBaos = new ByteArrayOutputStream(); soapResponse. writeTo (soapResponseBaos); String soapResponseXml = soapResponseBaos.toString(); return soapResponseXml; }
MessageFactory messageFactory = MessageFactory.newInstance(); TransformerFactory transformerFactory = TransformerFactory.newInstance(); SOAPConnectionFactory sfc = SOAPConnectionFactory.newInstance(); Document document = null; SOAPMessage requestMessage = messageFactory. createMessage (); Transformer transformer = transformerFactory.newTransformer(); DOMSource source = new DOMSource(document); DOMResult result = new DOMResult(requestMessage. getSOAPBody ()); transformer.transform(source, result); requestMessage. saveChanges (); URL endpoint = new URL( "http://example.com/endpoint" ); SOAPConnection connection = sfc. createConnection (); SOAPMessage responseMessage = connection. call (requestMessage, endpoint); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); responseMessage. writeTo (outputStream); System.out.println( new String(outputStream.toByteArray()));
Source: https://www.tabnine.com/code/java/classes/javax.xml.soap.SOAPConnectionFactory
0 Response to "Java Soapconnectionfactory 12 Example"
Post a Comment