Spring boot SpringBootSOAPWSDL不包含任何WSDL:portType部分
我是使用spring进行SOAP Web服务开发的新手,我已经为我的SOAP ws开发参考了以下网站。Spring boot SpringBootSOAPWSDL不包含任何WSDL:portType部分,spring-boot,soap,spring-ws,jaxb2,Spring Boot,Soap,Spring Ws,Jaxb2,我是使用spring进行SOAP Web服务开发的新手,我已经为我的SOAP ws开发参考了以下网站。https://www.concretepage.com/spring-boot/spring-boot-soap-web-service-example。我已经设置了演示应用程序,我能够生成wsdl文件。但是,当我使用与项目相关的XSD文件时,它是生成的wsdl文件,但在wsdl:portType部分下不包含任何内容 我已经使用以下xsd文件基于DefaultWsdl11Definition生
https://www.concretepage.com/spring-boot/spring-boot-soap-web-service-example
。我已经设置了演示应用程序,我能够生成wsdl文件。但是,当我使用与项目相关的XSD文件时,它是生成的wsdl文件,但在wsdl:portType
部分下不包含任何内容
我已经使用以下xsd文件基于DefaultWsdl11Definition
生成了wsdl。我的xsd文件在这里
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.com/"
targetNamespace="http://www.example.com/" elementFormDefault="qualified">
<xs:simpleType name="StatusCode">
<xs:restriction base="xs:string">
<xs:enumeration value="OK"/>
<xs:enumeration value="REQUEST_ERROR"/>
<xs:enumeration value="APPLICATION_ERROR"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="PatientStatus">
<xs:sequence>
<xs:element name="errorDescription" nillable="true" type="xs:string"/>
<xs:element name="statusCode" type="tns:StatusCode"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="parameters">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="parameter">
<xs:complexType>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:element name="createCaseForPatientRequestBody">
<xs:complexType>
<xs:sequence>
<xs:element name="caseId" nillable="true" type="xs:string"/>
<xs:element name="caseXML" nillable="false" type="xs:string"/>
<xs:element minOccurs="0" name="entityType" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="entityInstance" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="parameters" nillable="true" type="tns:parameters"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="createCaseForPatientSResponseBody">
<xs:complexType>
<xs:sequence>
<xs:element name="caseId" nillable="true" type="xs:string"/>
<xs:element name="screensURL" nillable="true" type="xs:string"/>
<xs:element name="patientStatus" nillable="false" type="tns:PatientStatus"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
wsconfig.java
public class WSConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/soapws/*");
}
@Bean(name = "articles")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema articlesSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("ArticlesPort");
wsdl11Definition.setLocationUri("/soapws");
wsdl11Definition.setTargetNamespace("http://www.example.com/");
wsdl11Definition.setSchema(articlesSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema articlesSchema() {
return new SimpleXsdSchema(new ClassPathResource("xsd/articles.xsd"));
}
}
默认情况下,
DefaultWsdl11Definition
将请求类型后缀定义为request
,将响应类型后缀定义为response
。
这可以在需要bean初始化时定制
更新xsd,使响应和请求的名称如下:
...
<xs:element name="createCaseForPatientRequest">
<xs:complexType>
<xs:sequence>
<xs:element name="caseId" nillable="true" type="xs:string"/>
<xs:element name="caseXML" nillable="false" type="xs:string"/>
<xs:element minOccurs="0" name="entityType" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="entityInstance" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="parameters" nillable="true" type="tns:parameters"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="createCaseForPatientResponse">
<xs:complexType>
<xs:sequence>
<xs:element name="caseId" nillable="true" type="xs:string"/>
<xs:element name="screensURL" nillable="true" type="xs:string"/>
<xs:element name="patientStatus" nillable="false" type="tns:PatientStatus"/>
</xs:sequence>
</xs:complexType>
</xs:element>
...
//...
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "createCaseForPatientRequest")
@ResponsePayload
public CreateCaseForPatientResponse createCaseForPatient(@RequestPayload CreateCaseForPatientRequest request) {
CreateCaseForPatientResponse response = new CreateCaseForPatientResponse();
response.setCaseId("ABC123");
response.setScreensURL("www.patientinfo.org");
response.setPatientStatus(new PatientStatus());
return response;
}
//...
你必须提供更多关于你所做工作的信息。你能发布你的端点(用@endpoint注释的类)定义和你的配置更新(类WSConfig)@AkliREGUIG-我已经更新了端点和WSConfig文件供你参考。
//...
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "createCaseForPatientRequest")
@ResponsePayload
public CreateCaseForPatientResponse createCaseForPatient(@RequestPayload CreateCaseForPatientRequest request) {
CreateCaseForPatientResponse response = new CreateCaseForPatientResponse();
response.setCaseId("ABC123");
response.setScreensURL("www.patientinfo.org");
response.setPatientStatus(new PatientStatus());
return response;
}
//...