SORU
11 NİSAN 2013, PERŞEMBE


Çalışma Soap istemci örnek

Çalışmıyor bulmak gibi görünüyor herhangi bir çalışma hizmeti ile JAVA (ha) basit SABUN bir örnek bulmaya çalışıyorum.

example one Bu denedim ama işe yaramıyor, bana bir eğik çizgi koymak istiyorum ama orada hiçbir şey olmuyor.

Bu yüzden herkes/istek ve karmaşa İndirebilirim herhangi bir SABUN örneği bağlantılar, biliyor mu?

Yardımlarınız için teşekkürler.

CEVAP
11 NİSAN 2013, PERŞEMBE


Java basit SABUN müşterileri uygulamak için SAAJ çerçevesi (JSE 1.6 ile birlikte gelen ve yukarıda) kullanabilirsiniz

Ekleri ile SABUN Java için (SAAJ) APIağırlıklı olarak doğrudan herhangi bir Web Hizmeti API sahne arkasında olur SOAP İstek/Cevap mesajları ile başa çıkmak için kullanılır. Geliştiriciler doğrudan ve JAX-WS kullanarak yerine sabun iletileri göndermek ve almak için izin verir.

Bakın aşağıda bir örnek çalışma (run!) SOAP web servis çağrısı SAAJ kullanarak. this web service çağırır.

import javax.xml.soap.*;

public class SOAPClientSAAJ {

    public static void main(String args[]) throws Exception {
        // Create SOAP Connection
        SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection soapConnection = soapConnectionFactory.createConnection();

        // Send SOAP Message to SOAP Server
        String url = "http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx";
        SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);

        // print SOAP Response
        System.out.print("Response SOAP Message:");
        soapResponse.writeTo(System.out);

        soapConnection.close();
    }

    private static SOAPMessage createSOAPRequest() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();

        String serverURI = "http://ws.cdyne.com/";

        // SOAP Envelope
        SOAPEnvelope envelope = soapPart.getEnvelope();
        envelope.addNamespaceDeclaration("example", serverURI);

        /*
        Constructed SOAP Request Message:
        <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="http://ws.cdyne.com/">
            <SOAP-ENV:Header/>
            <SOAP-ENV:Body>
                <example:VerifyEmail>
                    <example:email>mutantninja@gmail.com</example:email>
                    <example:LicenseKey>123</example:LicenseKey>
                </example:VerifyEmail>
            </SOAP-ENV:Body>
        </SOAP-ENV:Envelope>
         */

        // SOAP Body
        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");

        soapMessage.saveChanges();

        /* Print the request message */
        System.out.print("Request SOAP Message:");
        soapMessage.writeTo(System.out);
        System.out.println();

        return soapMessage;
    }

}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • AllYourNewsByMe

    AllYourNewsB

    18 Temmuz 2011
  • Ciaran Blumenfeld

    Ciaran Blume

    20 NİSAN 2009
  • Manuel Vizcaino

    Manuel Vizca

    27 Mayıs 2008