0
您好我正在嘗試創建一個@endpoint SOAP服務,但是當我嘗試獲取WSDL時,我得到了一個不允許的405方法。Spring-WS SOAP端點405方法不允許
還有就是我的服務端點:
@Endpoint
public class SubscribeMemberService {
public static final String NAMESPACE_URI = "urn:v1.webservice.subscription.test.org";
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "subscribe")
@ResponsePayload
public SubscribeMemberResponse subscribe(@RequestPayload SubscribeMemberRequest request) throws SubscribeMemberFault_Exception {
LOG.info("request received: LastName:" + request.getName().getLastName());
SubscribeMemberResponse response = new SubscribeMemberResponse();
response.setInfoMessage("Subscription of " + request.getName().getLastName());
LOG.info("sending response:" + request.getName().getLastName());
return response;
}
}
而且還有我的WS配置:
@EnableWs
@Configuration
@ComponentScan("org.test")
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
@Bean(name = "subscribeMember")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema subscribeMember) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("subscribeMemberPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace(SubscribeMemberService.NAMESPACE_URI);
wsdl11Definition.setSchema(subscribeMember);
return wsdl11Definition;
}
@Bean
public XsdSchema subscribeMemberSchema() {
return new SimpleXsdSchema(new ClassPathResource("META-INF/wsdl/subscribeMember.xsd"));
}
}
難道是鏈接到WebSecurityConfigurerAdapter?因爲在/ ws/*我沒有404找不到,但我得到405不允許。有任何想法嗎?
注:在WebSecurityConfigurerAdapter類保安過濾器是
protected void configure(HttpSecurity http) throws Exception {
http.httpBasic()
.and()
.authorizeRequests()
.anyRequest().hasRole("mySuperRole").and()
.csrf().disable();
}
也許我找到了問題「獲得405(不允許的方法)錯誤代碼訪問與SOAP服務時瀏覽器(即通過GET)實際上是正確的行爲:所有的SOAP HTTP訪問都是通過POST來完成的,而不是GET。 您可以嘗試在WSDL(例如SoapUI)中指向SOAP客戶端,並查看它是否可用代替。」 https://stackoverflow.com/questions/27198987/soap-webservice-endpoint-from-wsdl我會用SoapUI測試 – user1810567
不,它不適用於SOAP UI:「加載[http:// localhost:8080/subscription- webservice/v1/ws/SubscribeMemberService?wsdl]:org.apache.xmlbeans.XmlException:org.apache.xmlbeans.XmlException:錯誤:nul後文件意外結束。無論如何,wsdl文件應該可以通過GET訪問。 – user1810567