Java Soap Client Request Example

Best Java code snippets using javax.xml.soap.SOAPConnection.call (Showing top 20 results out of 315)

                                                                                                                                        SOAPMessage soapResponse = soapConnection.                                                              call                                                              (createSOAPRequest(), url);                                                                                                                                    
                                                                                                                                        SOAPMessage soapResponse = soapConnection.                                                              call                                                              (createSOAPRequest(), url);                                                                                                                                    
                                                                                                                                        SOAPMessage soapResponse = soapConnection.                                                              call                                                              (createSOAPRequest(), url);                                                                                                                                    
                                                                                                                  SOAPConnectionFactory soapConnectionFactory =  SOAPConnectionFactory.newInstance();                                                        SOAPConnection connection = soapConnectionFactory.createConnection();                                                                                                  java.net.URL endpoint =                                                                                    new                                                                                      URL(                                                              "url"                                                              );                                                                                                  SOAPMessage message = xmlStringParser.getSoapMessageFromString(XMLString);                                                                                                  SOAPMessage response = connection.                                                              call                                                              (message, endpoint);                                                                            
                                                                                                                  SOAPConnection connection = IpspSOAPConnectionFactory.newInstance().createConnection();                                                                                                  SOAPMessage responseSoap = connection.                                                              call                                                              (requestSoap, webServiceUrl);                                                                                                  String[] someHeader = responseSoap.getMimeHeaders().getHeader(someHeaderName);                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        protected                                                                                      SOAPMessage executeQuery(SOAPMessage message, URL url)                                                                                                  {                                                                                                                                                                                      try                                                                                                                                                                                    {                                                                                                                          SOAPMessage soapResult = connection.                                                              call                                                              (message, url);                                                                                                                                                                                                                                return                                                                                      soapResult;                                                                                                                      }                                                                                                                                                                                      catch                                                                                      (SOAPException e)                                                                                                                      {                                                                                                                          log.error(                                                              "Message-Call failed."                                                              , e);                                                                                                                                                                                                                                throw                                                                                                                                                  new                                                                                      JRRuntimeException(e);                                                                                                                      }                                                        }                                                                                          
                                                                                              MessageFactory msgFactory     = MessageFactory.newInstance();                                                                            SOAPMessage message           = msgFactory.createMessage();                                                                                                                          String loginPassword =                                                                                    "user:password"                                                              ;                                                                                                                                                                    message.getMimeHeaders().addHeader(                                                              "Authorization"                                                              ,                                                                                    "Basic "                                                                                      +                                                                                    new                                                                                      String(Base64.encode(loginPassword.getBytes())));                                                                                                                      SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();                                                                            SOAPConnection soapConnection = soapConnectionFactory.createConnection();                                                                                                                                                                                                                                                                                                                                                                                                                                      String url =                                                                                    "http://servername/name1"                                                              ;                                                                                                                                                                    SOAPMessage soapResponse = soapConnection.                                                              call                                                              (message, url);                                                                            
                                                          @Override                                                                                                                                                                                      void                                                                                      sendRequest(SOAPMessage message)                                                                                    throws                                                                                      NotConnectedException {                                                                                                                                                                                                                                if                                                                                      (!connected)                                                                                                                                                                                                                                throw                                                                                                                                                  new                                                                                      NotConnectedException();                                                                                                                                                                                                                                                                                        new                                                                                      Thread(() -> {                                                                                                                                                                                                                                try                                                                                      {                                                                                                                                                                    events.receivedMessage(soapConnection.                                                              call                                                              (message, url));                                                                                                                                                                    }                                                                                    catch                                                                                      (SOAPException e) {                                                                                                                      disconnect();                                                                            }                                                                            }).start();                                                                            }                                                        }                                  
                                      @Override                                                                                                                                                                protected                                                                                                                                                  void                                                                                      sendRequest(                                                              final                                                                                      SOAPMessage message)                                                                                    throws                                                                                      NotConnectedException {                                                                                                                                                                                                                                if                                                                                      (!connected)                                                                                                                                                                                                                                throw                                                                                                                                                  new                                                                                      NotConnectedException();                                                                                                                                                                    Thread thread =                                                                                    new                                                                                      Thread(() -> {                                                                                                                                                                                                                                try                                                                                      {                                                                                                                                                                    SOAPMessage response = soapConnection.                                                              call                                                              (message, url);                                                                                                                      events.receivedMessage(response);                                                                                                                          }                                                                                    catch                                                                                      (SOAPException e) {                                                                                                                                                                    logger.warn(                                                              "sendRequest() failed"                                                              , e);                                                                                                                      disconnect();                                                                            }                                                                            });                                                                            thread.start();                                                        }                                                                                          
                                                                                                                  SOAPBody body = message.getSOAPBody();                                                                                                  QName bodyName =                                                                                    new                                                                                      QName(                                                              "http://www.webserviceX.NET"                                                              ,                                                                                    "GetAtomicNumber"                                                              );                                                                                                  SOAPBodyElement bodyElement = body.addBodyElement(bodyName);                                                                                                  SOAPElement symbol = bodyElement.addChildElement(                                                              "MyMetal"                                                              );                                                                                                                                            symbol.addTextNode(                                                              "iron"                                                              );                                                                                                  SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();                                                                                                  SOAPMessage response = connection.                                                              call                                                              (message, endpoint);                                                                                                  connection.close();                                                        message.writeTo(System.out);                                                        System.out.println();                                                        response.writeTo(System.out);                                                        System.out.println();                                  
                                                                                                                                                                                                                            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;                                                                                                  }                                  
                                                                                                                                                                                                      byte                                                              [] encoded = Files.readAllBytes(Paths.get(                                                              "C:\\Users\\timofb\\Documents\\test.txt"                                                              ));                                                                                                                                                                    String soapXml =                                                                                    new                                                                                      String(encoded, StandardCharsets.UTF_8);                                                                                                                      SOAPConnectionFactory soapConnectionFactory =                                                                            SOAPConnectionFactory.newInstance();                                                                                                                          java.net.URL endpoint =                                                                                    new                                                                                      URL(                                                              "http://"                                                                                      + ip +                                                                                    "/cs-repository/services/xds-iti41"                                                              );                                                                                                                      SOAPConnection connection = soapConnectionFactory.createConnection();                                                                            MessageFactory factory = MessageFactory.newInstance();                                                                                                                          SOAPMessage message = factory.createMessage(                                                              new                                                                                      MimeHeaders(),                                                                                    new                                                                                      ByteArrayInputStream(encoded));                                                                                                                      AttachmentPart attachment = message.createAttachmentPart();                                                                                                                          attachment.setContent(                                                              "sm_content"                                                              ,                                                                                    "text/plain"                                                              );                                                                                                                                                                    attachment.setContentId(                                                              "1.9f910338bf0cac0e783bfdec7e53be9237684caa8f8f4e6d@apache.org"                                                              );                                                                                                                      message.addAttachmentPart(attachment);                                                                                                                          SOAPMessage response = connection.                                                              call                                                              (message, endpoint);                                                                                                                                                                    ByteArrayOutputStream out =                                                                                    new                                                                                      ByteArrayOutputStream();                                                                                                                      response.writeTo(out);                                                                                                                          String strMsg =                                                                                    new                                                                                      String(out.toByteArray());                                                                                                                                                                                                                                return                                                                                      strMsg;                                                                            
                                                                                                                                              public                                                                                                                                                  void                                                                                      callWebService()                                                                                    throws                                                                                      SOAPException, IOException {                                                                                                                      SOAPMessage request = createEchoRequest();                                                                            SOAPConnection connection = connectionFactory.createConnection();                                                                                                                          SOAPMessage response = connection.                                                              call                                                              (request, url);                                                                                                                                                                                                                                if                                                                                      (!response.getSOAPBody().hasFault()) {                                                                                                                      writeEchoResponse(response);                                                                            }                                                                                                                                                                                      else                                                                                      {                                                                                                                      SOAPFault fault = response.getSOAPBody().getFault();                                                                                                                          System.err.println(                                                              "Received SOAP Fault"                                                              );                                                                                                                                                                    System.err.println(                                                              "SOAP Fault Code :"                                                                                      + fault.getFaultCode());                                                                                                                                                                    System.err.println(                                                              "SOAP Fault String :"                                                                                      + fault.getFaultString());                                                                                                                      }                                                        }                                                                                          
                                                                                @Test(expected = NetworkReactiveAuditException.                                                              class                                                              )                                                                                                                                                                                                          public                                                                                                                                                  void                                                                                      call()                                                                                                                                                                                                                                throws                                                                                      SOAPException                                                                                                  {                                                                            TestTools.strict.commit();                                                                                                                          x.                                                              call                                                              (null, null);                                                                                                  }                                                                                          
                                                                                                                                              public                                                                                                                                                  void                                                                                      sendSoapMessage(String url)                                                                                    throws                                                                                      SOAPException, IOException {                                                                                                                      SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();                                                                            soapConnection = soapConnectionFactory.createConnection();                                                                                                                                                                                      try                                                                                      {                                                                                                                                                                    soapResponse = soapConnection.                                                              call                                                              (request, url);                                                                                                                                                                    }                                                                                    catch                                                                                      (Exception e) {                                                                                                                      logErrorToSystemOut(e);                                                                                                                                                                                      throw                                                                                                                                                  new                                                                                      CommandException(                                                              "The request resulted in an error: "                                                                                      + e.getMessage());                                                                                                                      }                                                                            logResponseToSystemOut();                                                                            closeSoapConnection();                                                                            storeResponseAsString();                                                        }                                                                                          
                                                                                                                                              public                                                                                      SOAPMessage sendMessage()                                                                                    throws                                                                                      Exception {                                                                                                                      SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();                                                                                                                                    SOAPConnection connection = conFactory.createConnection();                                                                            MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);                                                                            SOAPMessage msg = msgFactory.createMessage();                                                                                                                          SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(                                                              new                                                                                      QName(                                                              "urn:switchyard-quickstart:soap-mtom:1.0"                                                              ,                                                                                    "image"                                                              ));                                                                                                                      bodyElement.setTextContent(imageData);                                                                                                                                                                                                                                              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                                                                                                                                                  void                                                                                      runTest(Properties properties)                                                                                                  {                                                                                                                                                                                      try                                                                                      {                                                                                                                      Object jibxMessage = createMessage(properties);                                                                                                                                    SOAPMessage soapMessage = createSOAPMessage(jibxMessage);                                                                                                                                    SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();                                                                                                                          SOAPMessage soapResponse = connection.                                                              call                                                              (soapMessage, getEndpoint(properties));                                                                                                                      connection.close();                                                                                                                                    Object res = getResponseFromSOAPMessage(soapResponse, getResponseClass(jibxMessage));                                                                            checkResponseMessage(properties, res);                                                                                                                          }                                                                                    catch                                                                                      (SOAPException e) {                                                                                                                      e.printStackTrace();                                                                            }                                                        }                                                        /**                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            public                                                                                                                                                  void                                                                                      runTest(Properties properties)                                                                                                  {                                                                                                                                                                                      try                                                                                      {                                                                                                                      Object jibxMessage = createMessage(properties);                                                                                                                                    SOAPMessage soapMessage = createSOAPMessage(jibxMessage);                                                                                                                                    SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();                                                                                                                          SOAPMessage soapResponse = connection.                                                              call                                                              (soapMessage, getEndpoint(properties));                                                                                                                      connection.close();                                                                                                                                    Object res = getResponseFromSOAPMessage(soapResponse, getResponseClass(jibxMessage));                                                                            checkResponseMessage(properties, res);                                                                                                                          }                                                                                    catch                                                                                      (SOAPException e) {                                                                                                                      e.printStackTrace();                                                                            }                                                        }                                                        /**                                  
                                                                                                                                              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));                                                                                                  }                                                                                          

cookforsel.blogspot.com

Source: https://www.tabnine.com/code/java/methods/javax.xml.soap.SOAPConnection/call

0 Response to "Java Soap Client Request Example"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel