最近试着将POJOwebservice打包成war部署到JBoss上(同样的war部署在Glassfish上运行良好)下面是小结
一部署jaxws/POJOWebService到JBossGA
必须为你的POJOWebService定义一个Servlet并定义service的endpoint
这意味着必须修改/增加两个文件WEBINF/webxmlWEBINF/sunjaxwsxml(附文后)
最好将所需的jaxwsjars放到WENINF/lib里免得将这些jar拷贝来拷贝去
本人曾试了半天拷来拷去反正是搞不定最后还是一古脑儿索性全放到WEBINF/lib里倒是爽快:
WEBINF/lib/jaxwsrtjar
WEBINF/lib/jaxwstoolsjar
WEBINF/lib/logjjar
WEBINF/lib/saajapijar
WEBINF/lib/saajimpljar
WEBINF/lib/sjsxpjar
WEBINF/lib/staxexjar
WEBINF/lib/streambufferjar
WEBINF/lib/sxalanjar
别问我到底哪个是哪个都是干什么的
二部署jaxws/POJOWebService到JBossGA
好像是去年JBoss面世了根据其ReleaseNote它是thefinalreleaseoftheJBossseriesfortheJavaEE;codebasethatfullycomplieswiththeJavaEEconformancetestingcertificationrequirements但本人的试验结果却是大失所望如果将我们的webservice打包成war部署到JBoss上根本就不工作问题多去了为什么同样的war部署在Glassfish上就运行良好呢?果真是fullycomplieswiththeJavaEE?看起来并不那么fully
JBossGA的serverclassloader搜寻路径发生了一点变化根据其ReleaseNote的指示:WhenrunningunderJavayouneedtomanuallycopythefollowinglibrariesfromtheJBOSS_HOME/clientdirectorytotheJBOSS_HOME/lib/endorseddirectorysothattheJAXWSapissupportedbyJBossWSareused:
jbosswsnativesaajjar
jbosswsnativejaxrpcjar
jbosswsnativejaxwsjar
jbosswsnativejaxwsextjar
这个也无济于事
最终还得像部署在JBossGA上一样进行部署
总结
1将jaxws/POJOwebservice部署得到JBoss/是一样费劲的
2基本上需要两步一是要定义WEBINF/webxml和WEBINF/sunjaxwsxml二是要将所需的相关的wslibs放到war的本地classpath上
3还发现一个怪现象@WebServiceattribute是否附值与附哪些值JBoss与Glassfish所由此产生的wsdl内容很不相同这有点儿头痛
WhyJBossthen?答案是我儿子的口头禅我也不知道!
附上相关文件
{code}
serviceinterface:VodOptService
packagecomvodwsserviceopt;
importjavaxjwsWebMethod;
importjavaxjwsWebParam;
importjavaxjwsWebResult;
importjavaxjwsWebService;
importjavaxjwssoapSOAPBinding;
importcomvodwsserviceGetPersonRequest;
importcomvodwsserviceGetPersonResponse;
@WebService
@SOAPBinding(
style=SOAPBindingStyleDOCUMENT
use=SOAPBindingUseLITERAL
parameterStyle=SOAPBindingParameterStyleBARE
)
publicinterfaceVodOptService{
@WebMethod
@WebResult(name=getPersonResponse
targetNamespace=
partName=getPersonResponse)
publicGetPersonResponsegetPerson(@WebParam(name=getPersonRequest
targetNamespace=
partName=getPersonRequest)
GetPersonRequestrequest);
}
serviceimplementation:VodOptServiceImp
packagecomvodwsserviceopt;
importjavautilArrayList;
importjavaxjwsWebService;
importorgapachelogjLogger;
importcomvodwsserviceGetPersonRequest;
importcomvodwsserviceGetPersonResponse;
importcomvodwsservicePerson;
importcomvodwsserviceServiceResponseServiceMessage;
@WebService(serviceName=optsvsendpointInterface=comvodwsserviceoptVodOptService)
publicclassVodOptServiceImpimplementsVodOptService{
privatestaticfinalLoggerlog=LoggergetLogger(VodOptServiceImpclass);
privatestaticfinalStringMSISDN=;
publicGetPersonResponsegetPerson(GetPersonRequestrequest){
GetPersonResponseresponse=newGetPersonResponse();
if(request==null){
logerror(johnservicerequestisnull);
ServiceMessageMessagemsg=newServiceMessageMessage();
msgsetContent(Sorryrequestisnull);
msgsetLevel(ERROR);
ArrayList<ServiceMessageMessage>msglist=newArrayList<ServiceMessageMessage>();
msglistadd(msg);
ServiceMessageerror=newServiceMessage();
errorgetMessages()addAll(msglist);
responsesetServiceMessage(error);
returnresponse;
}
Stringmsisdn=requestgetMsisdn();
logdebug(Gettingpersonformsisdn:+msisdn);
Personperson=newPerson();
personsetFirstName(jason);
personsetLastName(wang);
personsetMsisdn(MSISDN);
responsesetPerson(person);
returnresponse;
}
}
WEBINF/webxml
<?xmlversion=encoding=UTF?>
<!servletjsp>
<webappxmlns:xsi=instance
xmlns=
xmlns:web=app__xsd
xsi:schemaLocation=;
app__xsdid=WebApp_ID
version=>
<displayname>vodws</displayname>
<description>vodws</description>
<!jwang:necessaryifdeployingtoJBossxnotrequiredforGlassfish>
<listener>
<listenerclass>
comsunxmlwstransport
</listenerclass>
</listener>
<servlet>
<description>vodoptwebservice</description>
<displayname>vodoptwebservice</displayname>
<servletname>VodOptService</servletname>
<servletclass>comsunxmlwstransport;/servletclass>
<loadonstartup></loadonstartup>
</servlet>
<servletmapping>
<servletname>VodOptService</servletname>
<urlpattern>/optsvs</urlpattern>
</servletmapping>
<!othewebxmlcontent>
</webapp>
WEBINF/sunjaxwsxml
<?xmlversion=encoding=UTF?>
<!jwang:thisfileisrequiredifdeployingtoJBossxnotrequiredforGlassfish>
<endpoints
xmlns=ws/ri/runtime
version=>
<endpoint
name=VodOptService
implementation=comvodwsserviceoptVodOptServiceImp
service={}VodOptService
port={}VodOptService
urlpattern=/optsvs/>
</endpoints>
{code}