Spring Boot Soap WSDL 不包含任何内容 wsdl:portType 部分
Spring Boot Soap WSDL doesnt contain anything wsdl:portType section
我是使用 spring 进行 SOAP web 服务开发的新手,我参考了以下网站进行 soap ws 开发。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>
请指正我在做什么 wrong.I 一直在努力找出问题所在。请帮忙。提前致谢。
终点
private static final String NAMESPACE_URI = "http://www.example.com/";
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "createCaseForPatient")
@ResponsePayload
public createCaseForPatientResponse createCase(@RequestPayload createCaseForPatientRequest request) {
createCaseForPatientResponse response = new createCaseForPatientResponse();
response.setCaseId("ABC123");
response.setScreensURL("www.patientinfo.org");
response.setPatientStatus("ACTIVE")
return response;
}
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;
}
//...
我是使用 spring 进行 SOAP web 服务开发的新手,我参考了以下网站进行 soap ws 开发。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>
请指正我在做什么 wrong.I 一直在努力找出问题所在。请帮忙。提前致谢。
终点
private static final String NAMESPACE_URI = "http://www.example.com/";
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "createCaseForPatient")
@ResponsePayload
public createCaseForPatientResponse createCase(@RequestPayload createCaseForPatientRequest request) {
createCaseForPatientResponse response = new createCaseForPatientResponse();
response.setCaseId("ABC123");
response.setScreensURL("www.patientinfo.org");
response.setPatientStatus("ACTIVE")
return response;
}
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;
}
//...