Lalitkumar.annaldas
Lalitkumar.annaldas

Reputation: 216

How to host a SOAP or WebService Endpoint using wsdl having localpath without Request or Response Suffix

I am new to creating Webservice using Spring boot. I am trying to host a SOAP Service using WSDl. I generated classes from WSDL which doesnt have suffix as Request or Response. The Class generated is as below:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"uniqueid"
})
@XmlRootElement(name = "EMPLOYEE_DETAILS")
public class EMPLOYEEDETAILS{

@XmlElement(name = "UNIQUE_ID")
protected String uniqueid;



public String getUNIQUEID() {
    return uniqueid;
}


public void setUNIQUEID(String value) {
    this.uniqueid = value;
}

}

I have extended WsConfigurerAdapter as below: @EnableWs @Configuration public class WebServiceConfig extends WsConfigurerAdapter {

@Value("${application.emp-details-wsdl-server.registration.location}")
private String wsdlLocation;

@Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
    MessageDispatcherServlet servlet = new MessageDispatcherServlet();
    servlet.setApplicationContext(applicationContext);
    servlet.setTransformWsdlLocations(true);
    return new ServletRegistrationBean<>(servlet, wsdlLocation+"/*");
}



@Bean(name = "employeeDetailsWS")
public DefaultWsdl11Definition employeeDetailsWsdl11Definition(@Qualifier("employeeDetailsSchema") XsdSchema employeeDetailsSchema) {
    DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
    wsdl11Definition.setPortTypeName("employeeDetailsPort");
    wsdl11Definition.setLocationUri(wsdlLocation+"/fetchemployeeRoles");
    wsdl11Definition.setTargetNamespace("http://xmlns.myservice.com/schema");
    wsdl11Definition.setSchema(employeeDetailsSchema);
    //wsdl11Definition.setRequestSuffix("Request");
    //wsdl11Definition.setResponseSuffix("Response");
    return wsdl11Definition;
}

@Bean(name="employeeDetailsSchema")
public XsdSchema employeeDetailsSchema() {
    return new SimpleXsdSchema(new ClassPathResource("xsd/Employee.xsd"));
}

Created Endpoint Class as below:

@Endpoint
@Component
public class EmployeeWebService {

private static final String NAMESPACE_URI = "http://xmlns.myservice.com/schema";

@WebMethod
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "EMPLOYEE_DETAILS")
@ResponsePayload
public EmployeeRoles getEmployeeRoles(@RequestPayload EMPLOYEEDETAILS){
    EmployeeRoles employeeRoles= new EmployeeRoles ();
    employeeRoles.setMESSAGE("Admin");
    employeeRoles.setSTATUSCODE("200");
    return employeeRoles;
 }
}

The above code works fine if i change the Class Name manually to EMPLOYEEDETAILSRequest and EmployeeRolesResponse but it doesnt work if the class name is not suffixed with Request or Response. Can someone help me where i am going wrong as i need to host the SOAP Service having structure without those suffix.

Upvotes: 0

Views: 21

Answers (0)

Related Questions