【WebService】新版JDK、JDK17如何使用WebService

JDK17如何使用WebService

百度到的答案都太乱了。。而且全是很老的答案,实际上用起来会报各种错误。

首先

WebService是一个很老的技术了,能选的话就别选它了。如果是对方用了webservice要求你去对接,也有别的选择,例如:
HttpClient ,自定义xml格式的字符串,用HTTP向对方接口发起请求。


其次

如果你莫得选择,只能用webservice,推荐JDK1.8版本,能直接调用接口


最后

如果你像我这样,项目用的新版本JDK,导致webservice一堆错误的话,

使用maven或者gradle依赖以下包

    <dependency>
    	<groupId>com.sun.xml.messaging.saaj</groupId>
    	<artifactId>saaj-impl</artifactId>
    	<version>1.5.2</version>
	</dependency>
	<dependency>
	    <groupId>jakarta.xml.soap</groupId>
	    <artifactId>jakarta.xml.soap-api</artifactId>
	    <version>2.0.1</version>
	</dependency>
	<dependency>
	    <groupId>javax.xml.bind</groupId>
	    <artifactId>jaxb-api</artifactId>
	    <version>2.3.1</version>
	</dependency>
	<dependency>
	    <groupId>com.sun.xml.bind</groupId>
	    <artifactId>jaxb-core</artifactId>
	    <version>3.0.2</version>
	</dependency>
	<dependency>
	    <groupId>com.sun.xml.bind</groupId>
	    <artifactId>jaxb-impl</artifactId>
	    <version>3.0.2</version>
	</dependency>
	<dependency>
	    <groupId>javax.xml.ws</groupId>
	    <artifactId>jaxws-api</artifactId>
	    <version>2.3.1</version>
	</dependency>

注意:saaj-impl这个包要用1.5.2,不能用新版,不然会报下面这个错
Unable to create SAAJ meta-factory: Provider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found


感谢以下链接的答者
https://stackoverflow.com/questions/48626824/java-lang-noclassdeffounderror-javax-xml-soap-soapexception
https://stackoverflow.com/questions/65791963/unable-to-create-saaj-meta-factory-provider-com-sun-xml-internal-messaging-saaj

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值