Spring Boot Soap WSDL doesnt contain anything wsdl:portType section

1.3k Views Asked by At

I am new to SOAP webservices development using spring and I have referred the following website for my soap ws development.https://www.concretepage.com/spring-boot/spring-boot-soap-web-service-example. I have setup the demo application i am able to generate the wsdl file. however when I used my project related XSD file it is generated wsdl file but it doesnt contain anything under wsdl:portType section.

I have used the following xsd file to generate wsdl based on DefaultWsdl11Definition. my xsd file is here.

<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>

Please correct me where I am doing wrong.I have been trying to figure out the issue. Please help. Thanks in advance .

End Point

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"));
}
}
1

There are 1 best solutions below

0
Akli REGUIG On BEST ANSWER

By default DefaultWsdl11Definition define the request type suffix as Request and the response type suffix as Response. This can be customised during the bean initialisation is needed.

update your xsd so the response and the request are named as follow :

...
    <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>
...

and your operation definition as follow :

//...
    @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;
    }
//...