加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

关于.NET和AXIS交流webservice的开发

发布时间:2020-12-17 02:32:39 所属栏目:安全 来源:网络整理
导读:???? 此次所做的是使用axis为.NET提供webservice,关于.NET和axis数据webservice数据交流的文章,有一篇很有借鉴性的文章(http://web.nchu.edu.tw/~jlu/cyut/axis/axis1net.shtml#aspx)。该次做webservice使用服务调用方提供server的wsdl生成我们自己的服

???? 此次所做的是使用axis为.NET提供webservice,关于.NET和axis数据webservice数据交流的文章,有一篇很有借鉴性的文章(http://web.nchu.edu.tw/~jlu/cyut/axis/axis1net.shtml#aspx)。该次做webservice使用服务调用方提供server的wsdl生成我们自己的服务方法。做法如下:

????? 1.先根据wsdl生成所有的类和deploy.wsdd文件,方法:下载Axis地址 http://apache.freelamp.com/ws/axis/1_4/axis-bin-1_4.zip
?解压axis-bin-1_4.zip文件.运行CMD,切换到wsdl的当前目录.?
输入命令?
java -Djava.ext.dirs=E:/DataFiles/StudyDataFiles/JAVA/axis/axis-bin-1_4/lib org.apache.axis.wsdl.WSDL2Java -t -B -v -D -s -p com.chinamworld.services -c com.chinamworld.services.IsmpSpEngineImpl IsmpSpEngine.wsdl
com.chinamworld.services为生成JAVA文件的包名。

我直接使用的是jbuilder2006生成一个部署的工程,并使用jbuilder2006的axis来生成类和deploy.wsdd

D:/jbpace/ynyd>java -Djava.ext.dirs=D:/JBuilder2006/thirdparty/ws-axis/lib org.apache.axis.wsdl.WSDL
?2Java -t -B -v -D -s -pWebService.EMAS? -cWebService.EMAS. DataImportServer DataImportServer.wsdl
??

?java -Djava.ext.dirs=D:/JBuilder2006/thirdparty/ws-axis/lib org.apache.axis.wsdl.WSDL2Java -t -B -v -D -s -p WebService.EMAS? DataImportServer.wsdl
2.将需要的jar添加到工程的web-inf下的lib中,将类文件也拷贝到此。

注意,不要用jbuilder2006将新生成的类发布为webservice或使用jbuilder2006的axis.wsdd来生成webservice,那应该是不可能完成的。

3.自己手工写一个server-config.wsdd放置在web-inf下。将deploy.wsdd的<service。。。。service/>之间的内容添加在server-config.wsdd中,基本就完成webservice的server开发,部署就根据环境的需要做调整。

4.部署成功,首先要验证jar满足服务发布吗?在JBuilder Apache Axis Admin Console下Validate the local installation's configuration 。View the list of deployed web services 可以看到工程上发布的webservice。点击DataImportServerSoap (wsdl) wsdl可以看到xml文件样式就说明发布成功。

5.期间有些错误,我使用了自己的方式解决。

?<operation name="importStationData" qname="operNS:ImportStationData" xmlns:operNS="EMAS.WebService" returnQName="retNS:ImportStationDataResult" xmlns:retNS="EMAS.WebService" returnType="rtns:string" xmlns:rtns="http://www.w3.org/2001/XMLSchema" soapAction="EMAS.WebService/ImportStationData" >
??????? <parameter qname="pns:dt" xmlns:pns="EMAS.WebService" type="tns:>>ImportStationData>dt" xmlns:tns="EMAS.WebService"/>
????? </operation>
????? <parameter name="allowedMethods" value="importStationData"/>

?

<typeMapping
??????? xmlns:ns="EMAS.WebService"
??????? qname="ns:>>ImportStationData>dt"
??????? type="java:WebService.EMAS.ImportStationDataDt"
??????? serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
??????? deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
??????? encodingStyle=""
????? />

?

使用deploy的service时操作方法的写法是如上的;但查看wsdl会有如下的错:

Fault - makeTypeElement() was told to create a type "{EMAS.WebService}>>ImportStationData>dt",with no containing element
AxisFault
?faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
?faultSubcode:
?faultString: makeTypeElement() was told to create a type "{EMAS.WebService}>>ImportStationData>dt",with no containing element
?faultActor:
?faultNode:
?faultDetail:
?{http://xml.apache.org/axis/}hostname:miika 不能看到wsdl的xml。

?

6.后来我去掉所有的<operation 。。。/>并将其修改为如下:

???<parameter name="allowedMethods" value="*" />
???<parameter name="scope" value="Application" />

查看wsdl仍然还有上面的错误。 我将所有的<typeMapping />删除,可以看到正常的wsdl的xml。

另将<typeMapping />的内容修改如下也可以看到正常的wsdl的xml:

??? <typeMapping
??????? xmlns:ns="EMAS.WebService"
??????? qname="ns:>>ImportStationData>dt"
??????? type="java:WebService.EMAS.ImportStationDataDt"
??????? serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
??????? deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
??????? encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
??????? name=">>ImportStationData>dt"
????? />

但两样都有后台的信息如下:

- The class org.w3c.dom.NamedNodeMap does not contain a default constructor,which is a requirement
for a bean class.? The class cannot be converted into an xml schema type.? An xml schema anyType wil
l be used to define this class in the wsdl file.
- The class org.w3c.dom.NodeList does not contain a default constructor,which is a requirement for
a bean class.? The class cannot be converted into an xml schema type.? An xml schema anyType will be
?used to define this class in the wsdl file.
- The class org.w3c.dom.Node does not contain a default constructor,which is a requirement for a be
an class.? The class cannot be converted into an xml schema type.? An xml schema anyType will be use
d to define this class in the wsdl file.
- The class javax.xml.soap.SOAPElement is defined in a java or javax package and cannot be converted
?into an xml schema type.? An xml schema anyType will be used to define this class in the wsdl file.

- The class java.util.Iterator is defined in a java or javax package and cannot be converted into an
?xml schema type.? An xml schema anyType will be used to define this class in the wsdl file.
- The class org.xml.sax.Attributes does not contain a default constructor,which is a requirement fo
r a bean class.? The class cannot be converted into an xml schema type.? An xml schema anyType will
be used to define this class in the wsdl file.
- The class org.apache.axis.encoding.DeserializationContext does not contain a default constructor,
which is a requirement for a bean class.? The class cannot be converted into an xml schema type.? An
?xml schema anyType will be used to define this class in the wsdl file.
- The class javax.xml.soap.Name is defined in a java or javax package and cannot be converted into a
n xml schema type.? An xml schema anyType will be used to define this class in the wsdl file.
- The class org.apache.axis.soap.SOAPConstants does not contain a default constructor,which is a re
quirement for a bean class.? The class cannot be converted into an xml schema type.? An xml schema a
nyType will be used to define this class in the wsdl file.
- The class javax.xml.soap.SOAPBody is defined in a java or javax package and cannot be converted in
to an xml schema type.? An xml schema anyType will be used to define this class in the wsdl file.
- The class javax.xml.soap.SOAPHeader is defined in a java or javax package and cannot be converted
into an xml schema type.? An xml schema anyType will be used to define this class in the wsdl file.
- The class org.apache.axis.schema.SchemaVersion does not contain a default constructor,which is a
requirement for a bean class.? The class cannot be converted into an xml schema type.? An xml schema
?anyType will be used to define this class in the wsdl file.
- The class org.apache.axis.encoding.Deserializer does not contain a default constructor,which is a
?requirement for a bean class.? The class cannot be converted into an xml schema type.? An xml schem
a anyType will be used to define this class in the wsdl file.


但有生成和使用过的人说出现上面不能查看wsdl的错误和后面能看到wsdl但后台错的情形服务也能正常提供,就服务不稳定。

?

7.可以命令生成server-config.wsdd:

java -Djava.ext.dirs=D:/JBuilder2006/thirdparty/ws-axis/lib org.apache.axis.client.AdminClient -lhttp://localhost:7001/irmsWS/servlet/AxisServlet deploy.wsdd
查看服务的wsdl时,后台报错同6.

?

我也将做尽量的测试。


?注意:

在Axis里书写deploy.wsdd并利用org.apache.axis.client.AdminClient发布,其主要工作就是把<service>标签中的内容添加在server-config.wsdd里,所以一般直接编辑server-config.wsdd文件会更方便一些。不过当你还没有server-config.wsdd文件时,使用deploy.wsdd的方法会更方便些,因为AdminClient会帮你生成一些额外的xml元素(<handler>等等),而这些元素是必要的。

?

?使用该方式可以直接生成一部分客户端代码:

?java -Djava.ext.dirs=D:/JBuilder2006/thirdparty/ws-axis/lib org.apache.axis.wsdl.WSDL2Java http://10.168.65.35:7001/NewWebService/services/InterSwitchOmmWebService?wsdl

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读