i want learn spring-ws with automatic generation of wsdl files, i know that is a lot of tutorials, i tried them, my favorite example is :
It works well, but i tried to ajust that solution for my needs, and it doesnt work, i dont know why, and it is question for you, what is wrong here?
I was changed:
- models (oxm package in github project) - schema.xsd (ecommerce.xsd in github project) as well
- EndpointClass
- remove classes: SubscriptionPort.java and SubscriptionPortService.java (I noticed that are not needed for proper operation) (when remove from github project everything was good)
and my generated wsdl file have no wsdl:operation tag (should be in PortType tag)...
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch="http://localhost:8080/ws/schema/oss" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://localhost:8080/ws/schema/oss" targetNamespace="http://localhost:8080/ws/schema/oss">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://localhost:8080/ws/schema/oss" version="1.0">
<xs:complexType name="deliverShortMessageRequest">
<xs:sequence>
<xs:element minOccurs="0" name="parameters">
<xs:complexType>
<xs:sequence>
<xs:element name="sms" type="tns:deliverShortMessage"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="deliverShortMessageResponse">
<xs:sequence>
<xs:element name="deliverShortMessageReturn" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="deliverShortMessage">
<xs:sequence>
<xs:element minOccurs="0" name="sms" type="tns:smsMessage"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="smsMessage">
<xs:sequence>
<xs:element minOccurs="0" name="content" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:portType name="SubscriptionPort"></wsdl:portType>
<wsdl:binding name="SubscriptionPortSoap11" type="tns:SubscriptionPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
</wsdl:binding>
<wsdl:service name="SubscriptionPortService">
<wsdl:port binding="tns:SubscriptionPortSoap11" name="SubscriptionPortSoap11">
<soap:address location="/"/>
</wsdl:port>
</wsdl:service>
schema.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="http://localhost:8080/ws/schema/oss"
xmlns:tns="http://localhost:8080/ws/schema/oss">
<xs:complexType name="deliverShortMessageRequest">
<xs:sequence>
<xs:element name="parameters" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="sms" type="tns:deliverShortMessage"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="deliverShortMessageResponse">
<xs:sequence>
<xs:element name="deliverShortMessageReturn" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="deliverShortMessage">
<xs:sequence>
<xs:element name="sms" type="tns:smsMessage" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="smsMessage">
<xs:sequence>
<xs:element name="content" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
my simple Endpoint class:
@Endpoint
public class MessageEndpoint {
private static final String NAMESPACE_URI = "http://localhost:8080/ws/schema/oss";
@PayloadRoot(namespace = NAMESPACE_URI, localPart = "DeliverShortMessageRequest")
@ResponsePayload
public DeliverShortMessageResponse deliverShortMessage(@RequestPayload DeliverShortMessageRequest deliverShortMessageRequest) {
System.out.println("deliverShortMessage " + deliverShortMessageRequest);
DeliverShortMessageResponse result = new DeliverShortMessageResponse();
result.setDeliverShortMessageReturn(true);
return result;
}
}
spring-ws config:
<sws:annotation-driven />
<sws:interceptors>
<bean id="validatingInterceptor" class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"
p:schema="/WEB-INF/schema.xsd"
p:validateRequest="true"
p:validateResponse="true"/>
<bean id="loggingInterceptor" class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
</sws:interceptors>
<sws:dynamic-wsdl id="subscription"
portTypeName="SubscriptionPort"
locationUri="/"
targetNamespace="http://localhost:8080/ws/schema/oss">
<sws:xsd location="/WEB-INF/schema.xsd"/>
</sws:dynamic-wsdl>
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"
p:contextPath="org.krams.tutorial.model"/>
<bean id="marshallingPayloadMethodProcessor" class="org.springframework.ws.server.endpoint.adapter.method.MarshallingPayloadMethodProcessor">
<constructor-arg ref="jaxbMarshaller"/>
<constructor-arg ref="jaxbMarshaller"/>
</bean>
<bean id="defaultMethodEndpointAdapter" class="org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter">
<property name="methodArgumentResolvers">
<list>
<ref bean="marshallingPayloadMethodProcessor"/>
</list>
</property>
<property name="methodReturnValueHandlers">
<list>
<ref bean="marshallingPayloadMethodProcessor"/>
</list>
</property>
</bean>
When I searching an answers why it is happening I found replice like: Spring-WS generates WSDL without operations Spring-WS WSDL Generation Problem but as you can see my request and response objects have Request and Response suffix
do you have any ideas what i forgot? and why in wsdl i have no operation tag? it looks like he doesnt see Endpoint operation or there is some letter mismatch
The problem is that your xsd is wrong. You should wrap your complex types in an element.