Java 类javax.xml.messaging.URLEndpoint 实例源码

项目:parabuild-ci    文件:UddiPing.java   
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();
}
项目:parabuild-ci    文件:DelayedStockQuote.java   
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;
}
项目:OSCAR-ConCert    文件:FrmStudyXMLClientSend.java   
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);
    }
}
项目:oscar-old    文件:FrmStudyXMLClientSend.java   
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 (Throwable e)   {
        MiscUtils.getLogger().error("Error", e);
    }
}
项目:oscar-old    文件:WebServiceClient.java   
private Element callWebService(Element bodyElement, String contentLocation)
        throws SOAPException,
        TransformerConfigurationException,
        TransformerException {
    SOAPConnection con = SOAPConnectionFactory.newInstance().createConnection();
    URLEndpoint endpoint = new URLEndpoint(url);

    SOAPMessage request = createRequest(bodyElement, contentLocation);

    SOAPMessage response = con.call(request, endpoint);

    con.close();
    return parseResponse(response);
}