关于webservice报Could not find destination factory for transport http://schemas.xmlsoap.org/soap/http错误

错误如下:

九月 21, 2022 6:25:48 下午 org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
信息: Creating Service {http://Imp.service.webservice.com/}ServerImpService from class com.webservice.service.Server
Exception in thread "main" org.apache.cxf.service.factory.ServiceConstructionException
	at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:193)
	at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
	at com.webservice.Server.main(Server.java:11)
Caused by: java.io.IOException: Could not find destination factory for transport http://schemas.xmlsoap.org/soap/http
	at org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTransportFactory.java:132)
	at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:85)
	at org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:64)
	at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:182)
	... 2 more

报这个错位的原因有两个:

原因1:未导入cxf-rt-transports-http-jetty依赖

解决办法:加入依赖

<dependency>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-rt-transports-http-jetty</artifactId>
    <version>3.4.3</version>
</dependency>

原因2:在发布服务的地址address地址写法不对

例:

package com.webservice;

import com.webservice.service.Imp.ServerImp;
import org.apache.cxf.jaxws.JaxWsServerFactoryBean;

public class Server {
    public static void main(String[] args) {
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        factory.setServiceBean(new ServerImp());
        factory.setAddress("127.0.0.1:9999/aa/bb);
        factory.create();
        System.out.println("服务发布成功,端口:9527");
    }
}

不能写  127.0.0.1:9999/aa/bb  而是应该写成  http://127.0.0.1:9999/aa/bb 

由于自己的疏忽大意本人就在第二处犯的错

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值