服务器不支持get请求,java - 请求行中接收到的方法对于原始服务器是已知的,但目标资源不支持 - 堆栈内存溢出...

我是Java的初学者,我在本教程中创建了一个使用Spring Boot和Maven的Soap Web服务,当我运行Application并在SoapUI中调用它时,一切正常,但是当我制作一个war文件并将其放入tomcat Web中时应用并尝试在SoapUI中调用它,则抛出以下错误:

HTTP状态405 –不允许的方法-此URL不支持HTTP方法POST。 在请求行中接收到的方法是源服务器已知的,但目标资源不支持。

在搜索了此错误之后,我找到了这个问题并得到了答案,但是我没有用于扩展HttpServlet的任何Servlet类,也没有任何使用ServletRegistrationBean的doGet()或doPost(),那么如何解决我的问题?

春季启动设置:

@SpringBootApplication

@ComponentScan(basePackages={"com.sinap"})

public class DailySituationApplication extends SpringBootServletInitializer

{

@Override

protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

return application.sources(DailySituationApplication.class);

}

public static void main(String[] args) {

SpringApplication.run(DailySituationApplication.class, args);

}

}

WsConfigurerAdapter

@EnableWs

@Configuration

public class WebServiceConfig extends WsConfigurerAdapter {

@Bean

public ServletRegistrationBean messageDispatcherServlet(

ApplicationContext applicationContext) {

MessageDispatcherServlet servlet =

new MessageDispatcherServlet();

servlet.setApplicationContext(applicationContext);

return new ServletRegistrationBean<>(servlet,

"/DailySituation/ws/*");

}

@Bean(name = "DailySituation")

public Wsdl11Definition defaultWsdl11Definition() {

SimpleWsdl11Definition wsdl11Definition =

new SimpleWsdl11Definition();

wsdl11Definition

.setWsdl(new ClassPathResource("/wsdl/DailySituation.wsdl"));

return wsdl11Definition;

}

}

终点:

@Endpoint

public class SinapEndpoint {

@PayloadRoot(

namespace ="http://tempuri.org/",

localPart = "Insert")

@ResponsePayload

public InsertResponse InsertSinap(@RequestPayload Insert request) throws IDailySituationServiceInsert

SinapExceptionFaultFaultMessage {

DailySituation odailySituation = request.getDailySituation().getValue();

URL wsdlURL = DailySituationService.WSDL_LOCATION;

DailySituationService stub = new DailySituationService(wsdlURL);

IDailySituationService port = stub.getBasicHttpBindingIDailySituationService();

{

BindingProvider prov = (BindingProvider) port;

com.microsoft.schemas._2003._10.serialization.ObjectFactory objectFactory = new ObjectFactory();

org.tempuri.ObjectFactory of =new org.tempuri.ObjectFactory();

InsertResponse response =of.createInsertResponse();

try {

String result= port.insert(odailySituation);

JAXBElement _insert_return = objectFactory.createString(result);

response.setInsertResult(_insert_return);

}

catch (IDailySituationServiceInsertSinapExceptionFaultFaultMessage e) {

SinapException sinapException =new SinapException();

sinapException.setErrorCode(e.getFaultInfo().getErrorCode());

sinapException.setErrorMessage(e.getFaultInfo().getErrorMessage());

throw new IDailySituationServiceInsertSinapExceptionFaultFaultMessage("Error Code:" + e.getFaultInfo().getErrorCode() + "_"

+ e.getFaultInfo().getErrorMessage().getValue(),sinapException,e);

}

return response;

}

}

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值