Java SOAP API example
来源:互联网 发布:直销软件结算系统公司 编辑:程序博客网 时间:2024/05/22 16:42
http://stackoverflow.com/questions/15948927/working-soap-client-example
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; }}
0 0
- Java SOAP API example
- A SOAP Example in Java
- SOAP Example
- SOAP used in java -----First Example
- SOAP used in java -----First Example
- Apache CXF Spring SOAP example
- c api example
- libx264 api example
- API Document Example
- Apache CXF Spring SOAP MTOM example
- Apache CXF Spring SOAP Handler example
- JAVA EXAMPLE
- Magento SOAP API基础知识
- magento soap api 调用
- magento soap api
- Java SOAP
- java SOAP
- Salesforce中通过SOAP API和Metadata API开发java的web server服务
- 401. Binary Watch
- Ruler:一款利用Exchange服务渗透的安全工具
- 让C/S进行全双工通信的WebSocket协议
- LeetCode-371. Sum of Two Integers-Java
- UC 笔试题记录
- Java SOAP API example
- J2EE如何生成验证码图片和点击刷新验证码
- 音视频处理-图像格式-jpeg-tinyjpeg
- 415. Add Strings
- 读取联系人工具类模板
- Unity3D自学笔记——Photon服务器的后台架构实现(一)
- how to set custom navigator title
- 黑客修改WordPress核心文件,劫持网站流量
- MyEclipse之无法连接到MySQL数据库