I am using Spring boot 2.4.2 , and trying to create a SOAP Webservice from a given WSDL file.
My WSDL file looks like as following (................................ indicates omitted par as WSDL is very large):
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:gsstype="http://com.alcatel.au/opennet/nbgateway/gsstypes" xmlns:gsstypes="http://com.alcatel.au/opennet/nbgateway/gsstypes" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://opennet.com.sg/opennet/OnGSSNorthBoundGateway/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://opennet.com.sg/opennet/OnGSSNorthBoundGateway/">
<wsdl:types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://com.alcatel.au/opennet/nbgateway/gsstypes">
................................
<xsd:complexType name="CustomerPremises">
<xsd:annotation>
<xsd:documentation>CustomerPremises</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="SiteAddress" type="gsstypes:SiteAddress" />
<xsd:element minOccurs="0" name="HomePassedOrHomeReached" type="gsstypes:HomePassedOrHomeReached" />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="SiteAddress">
<xsd:annotation>
<xsd:documentation>Complex Address type which will be used as a base type for the rest of the Address.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element minOccurs="0" name="BuildingTypeID" type="gsstypes:varchar10" />
<xsd:element minOccurs="0" name="AddressHouseNumber" type="gsstypes:varchar10" />
<xsd:element minOccurs="0" name="AddressStreetName" type="gsstypes:varchar100" />
<xsd:element minOccurs="0" name="AddressFloorNumber" type="gsstypes:varchar3" />
<xsd:element minOccurs="0" name="AddressUnitNumber" type="gsstypes:varchar5" />
<xsd:element minOccurs="0" name="AddressBuildingName" type="gsstypes:varchar64" />
<xsd:element minOccurs="0" name="AddressPostCode" type="gsstypes:varchar6" />
</xsd:sequence>
</xsd:complexType>
................................
</xsd:schema>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://opennet.com.sg/opennet/OnGSSNorthBoundGateway/">
................................
<xsd:element name="CustomerPremisesForSCRequest" type="gsstypes:CustomerPremisesForSCRequest" />
<xsd:element name="CustomerPremisesForSCResponse" type="gsstypes:CustomerPremisesForSCResponse" />
<xsd:element name="gatewayAuthentication" nillable="false" type="tns:AuthenticationInfo" />
<xsd:complexType name="AuthenticationInfo">
<xsd:annotation>
<xsd:documentation>Represents authentication info. Will be passed with the request header</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="userName" nillable="false" type="xsd:string" />
<xsd:element name="password" nillable="false" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
</wsdl:types>
................................
<wsdl:message name="CustomerPremisesForSCRequest">
<wsdl:part element="tns:CustomerPremisesForSCRequest" name="parameters" />
</wsdl:message>
<wsdl:message name="gatewayAuthentication">
<wsdl:part element="tns:gatewayAuthentication" name="parameters" />
</wsdl:message>
<wsdl:message name="CustomerPremisesForSCResponse">
<wsdl:part element="tns:CustomerPremisesForSCResponse" name="parameters" />
</wsdl:message>
<wsdl:portType name="OnGSSNorthBoundGateway">
................................
<wsdl:operation name="customerPremisesForSC">
<wsdl:input message="tns:CustomerPremisesForSCRequest" />
<wsdl:output message="tns:CustomerPremisesForSCResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="OnGSSNorthBoundGatewaySOAP" type="tns:OnGSSNorthBoundGateway">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
................................
<wsdl:operation name="customerPremisesForSC">
<soap:operation soapAction="http://opennet.com.sg/opennet/GSSNetworkService/customerPremisesForSC" />
<wsdl:input>
<soap:header message="tns:gatewayAuthentication" part="parameters" use="literal" />
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="OnGSSNorthBoundGateway">
<wsdl:port binding="tns:OnGSSNorthBoundGatewaySOAP" name="OnGSSNorthBoundGatewaySOAP">
<soap:address location="http://10.65.111.157:8680/nb-workorder-gss/http/gateway" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
My configuration adapter looks like following:
@EnableWs
@Configuration
public class WeberviceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean<Servlet> messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
return new ServletRegistrationBean<>(servlet, "/nlt/ws/*");
}
@Bean(name = "nb-workorder-gss")
public Wsdl11Definition gssWsdl11Definition() {
SimpleWsdl11Definition wsdl11Definition = new SimpleWsdl11Definition();
wsdl11Definition.setWsdl(new ClassPathResource("nb-workorder-gss.wsdl"));
return wsdl11Definition;
}
}
And my End point looks like following:
@Endpoint
public class NBWorkorder {
private static final Logger LOGGER =
LoggerFactory.getLogger(NBWorkorder.class);
@PayloadRoot(namespace = "http://opennet.com.sg/opennet/OnGSSNorthBoundGateway/", localPart = "gsstypes:CustomerPremisesForSCRequest")
@ResponsePayload
private CustomerPremisesForSCResponse customerPremisesForSC(@RequestPayload CustomerPremisesForSCRequest request) {
LOGGER.info("i WAS HERE");
CustomerPremisesForSCResponse response = new CustomerPremisesForSCResponse();
ResponseMessage responseMsg = new ResponseMessage();
responseMsg.setMessageCode("0X0000");
responseMsg.setMessageDescription("This is testing ");
responseMsg.setMessageHead("HEAD");
response.setResponseMessage(responseMsg);
ServingCabinetDetails scDetails = new ServingCabinetDetails();
scDetails.setCOArea(AreaCode.AM);
SiteIdentifier si = new SiteIdentifier();
si.setSiteID("1212");
si.setSiteType("CO");
scDetails.setSiteIdentifier(si);
response.getServingCabinetDetails().add(scDetails);
return response;
}
}
All the tutorials that I can find for Spring Boot Webservices:
https://medium.com/swlh/publish-a-soap-web-service-with-spring-boot-b561a4142d81
I am assuming this is use the targetNameSpace in wsdl and embeded xsd are same , which is causing problem for me and I am getting an erorr :
No endpoint mapping found for [SaajSoapMessage {http://opennet.com.sg/opennet/OnGSSNorthBoundGateway/}CustomerPremisesForSCRequest]
Can someone help here .
My trace log looks like following:
Received request [<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:gss="http://com.alcatel.au/opennet/nbgateway/gsstypes" xmlns:ong="http://opennet.com.sg/opennet/OnGSSNorthBoundGateway/">
<soapenv:Header>
<ong:gatewayAuthentication>
<ong:userName>?</ong:userName>
<ong:password>?</ong:password>
</ong:gatewayAuthentication>
</soapenv:Header>
<soapenv:Body>
<ong:CustomerPremisesForSCRequest>
<!--Optional:-->
<gss:SiteID>?</gss:SiteID>
<gss:Postal_Code>?</gss:Postal_Code>
<!--Zero or more repetitions:-->
<gss:AdditionalParameter>
<gss:Name>?</gss:Name>
<gss:Value>?</gss:Value>
</gss:AdditionalParameter>
</ong:CustomerPremisesForSCRequest>
</soapenv:Body>
</soapenv:Envelope>]
2021-01-26 22:52:33.041 DEBUG 13456 --- [nio-8080-exec-3] yloadRootAnnotationMethodEndpointMapping : Looking up endpoint for [{http://opennet.com.sg/opennet/OnGSSNorthBoundGateway/}CustomerPremisesForSCRequest]
2021-01-26 22:52:33.041 DEBUG 13456 --- [nio-8080-exec-3] o.s.w.soap.server.SoapMessageDispatcher : Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping@40405125] has no mapping for request
2021-01-26 22:52:33.041 DEBUG 13456 --- [nio-8080-exec-3] oapActionAnnotationMethodEndpointMapping : Looking up endpoint for [http://opennet.com.sg/opennet/GSSNetworkService/customerPremisesForSC]
2021-01-26 22:52:33.041 DEBUG 13456 --- [nio-8080-exec-3] o.s.w.soap.server.SoapMessageDispatcher : Endpoint mapping [org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping@1d5daf98] has no mapping for request
2021-01-26 22:52:33.041 DEBUG 13456 --- [nio-8080-exec-3] o.s.w.soap.server.SoapMessageDispatcher : Endpoint mapping [org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping@4b9256d1] has no mapping for request
2021-01-26 22:52:33.041 WARN 13456 --- [nio-8080-exec-3] o.s.ws.server.EndpointNotFound : No endpoint mapping found for [SaajSoapMessage {http://opennet.com.sg/opennet/OnGSSNorthBoundGateway/}CustomerPremisesForSCRequest]
2021-01-26 22:52:33.041 DEBUG 13456 --- [nio-8080-exec-3] o.s.w.t.http.MessageDispatc
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…