12.Axis2 Web Service(三).docx

  1. 1、本文档共30页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
12.Axis2 Web Service(三)

一、SOAPIn Axis2在前两天的教程中,我们学习到了用Axis2如何进行复杂数据、简单数据进行传输。正如我在前一天教程中所说,在web service的世界里,一切都是基于SOAP的,因此在今天我们将学习Axis2中的SOAP特性。今天的课程将用3个例子来完成即:1)客户端与服务端使用SOAP进行通讯2)服务端将Exception以SOAPFault的形式抛给客户端3)使用SWA(Soap With Attachment)来进行附件传送?二、客户端与服务端使用SOAP进行通讯来看下面这个Web Service:下面是Service端的源码org.sky.axis2.soap.SoapServicepackage org.sky.axis2.soap;?import org.apache.axiom.om.OMAbstractFactory;import org.apache.axiom.om.OMElement;import org.apache.axiom.om.OMFactory;import org.apache.axiom.om.OMNamespace;importjava.util.*;?public class SoapService {public static OMElementrequestSoap = null;public OMElement request(OMElementsoapBody) {??requestSoap = soapBody;??Iterator it = requestSoap.getChildElements();????OMElementissuerElement = (OMElement) it.next();????OMElementserialElement = (OMElement) it.next();????OMElementrevocationDateElement = (OMElement) it.next();????String issuer = issuerElement.getText();????String serial = serialElement.getText();????String revocationDate = revocationDateElement.getText();????System.out.println(issuer===== + issuer);????System.out.println(serial===== + serial);????System.out.println(revocationDate===== + revocationDate);????OMFactorysoapFactory = OMAbstractFactory.getOMFactory();????OMNamespaceomNs = soapFactory.createOMNamespace(??????????????, );??????????????????OMElementsoapResponse = soapFactory.createOMElement(SoapResponse, omNs);?????OMElementsoapIssuer = soapFactory.createOMElement(Issuer, omNs);????soapIssuer.setText(issuer: + issuer);????soapResponse.addChild(soapIssuer);?OMElementsoapSerial = soapFactory.createOMElement(Serial, omNs);????soapSerial.setText(serial: + serial);????soapResponse.addChild(soapSerial);?OMElementsoapRevokeDate = soapFactory.createOMElement(RevokeDate,omNs);????soapRevokeDate.setText(RevocationDate: + revocationDate);????soapResponse.addChild(soapRevokeDate);????soapResponse.build();?return soapResponse;? }}来看它的service.xml的描述service name=SoapService???????? description?????????????????? This is the service for

文档评论(0)

yan698698 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档