Announcement Announcement Module
Collapse
No announcement yet.
soapAction attribute of operation when dynamically generating wsdl Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • soapAction attribute of operation when dynamically generating wsdl

    Hello:

    I've recently started playing around with Spring-WS and I've run into a little issue. I'm sure I've missed something so I was hoping someone can point me in the right direction. Ideally the setup that I'm after would be to configure in spring the dynamic generation of the WSDL (based on a defined XSD file) and map the endpoints based on SOAP actions.

    I'm getting an error in the log which indicates that there is no endpoint mapping for the SOAP request. When I took a look at the generated WSDL, the soapAction attribute of the operation is blank. Would this be causing the issue? I've looked at the class XsdBasedSoap11Wsdl4jDefinitionBuilder but I can't seem to find how to set the soapAction.

    Log file output:
    Code:
    DEBUG MessageDispatcher with name 'webservices' received request [org.springframework.ws.soap.saaj.SaajSoapMessage@60e277]
    DEBUG Endpoint mapping [org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping@152e9a8] has no mapping for request
    WARN  No endpoint mapping found for [org.springframework.ws.soap.saaj.SaajSoapMessage@60e277]
    DEBUG Successfully completed request
    In web.xml, I have added a servlet mapping for my webservices:
    Code:
    <servlet>
      <servlet-name>webservices</servlet-name>
      <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
    </servlet>
    <servlet-mapping>
      <servlet-name>webservices</servlet-name>
      <url-pattern>/ws/*</url-pattern>
    </servlet-mapping>
    In the webservices-servlet.xml, I have defined the SOAP action mappings, the dynamic WSDL and the service endpoint as follows:
    Code:
    <beans>
      
      <bean id="xstreamMarshaller" class="org.springframework.oxm.xstream.XStreamMarshaller" />
      
      <bean id="soapActionMapping" class="org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping">
        <property name="mappings">
          <props>
            <prop key="http://localhost:8080/ws/SubmitTest">
              submitTestEndpoint
            </prop>
          </props>
        </property>
      </bean>
      
      <bean id="submitTest" class="org.springframework.ws.wsdl.wsdl11.DynamicWsdl11Definition">
        <property name="builder">
          <bean class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
            <property name="schema" value="/WEB-INF/schemas/submitTest.xsd"/>
            <property name="portTypeName" value="SubmitTest"/>
            <property name="locationUri" value="http://localhost:8080/ws/SubmitTest"/>
          </bean>
        </property>
      </bean>
      
      <bean id="submitTestEndpoint" class="com.example.ws.SubmitTestEndpoint">
        <property name="marshaller" ref="xstreamMarshaller" />
        <property name="unmarshaller" ref="xstreamMarshaller" />
      </bean>
      
    </beans>
    Here is the relevant fragment from the generated WSDL at http://localhost:8080/ws/submitTest.wsdl:
    Code:
    <wsdl:binding name="SubmitTestBinding" type="schema:SubmitTest">
      <soap:binding style="document" transport="http://localhost:8080/ws/SubmitTest" /> 
      <wsdl:operation name="submitTest">
        <soap:operation soapAction="" /> 
        <wsdl:input name="submitTestRequest">
          <soap:body use="literal" /> 
        </wsdl:input>
        <wsdl:output name="submitTestResponse">
          <soap:body use="literal" /> 
        </wsdl:output>
      </wsdl:operation>
    </wsdl:binding>

    Any help would be greatly appreciated
    joey
    Last edited by joey; Feb 15th, 2007, 10:32 PM.

  • #2
    Yes, the dynamically generated WSDL contains blank SOAP Actions. This means that you cannot use the SoapActionEndpointMapping.

    There are three ways to solve this:
    • Supply a defaultEndpoint to the mapping. This means that every message will go to your endpoint, no matter what the SOAP ACtion is.
    • Override populateSoapOperation() on the XsdBasedSoap11Wsdl4jDefinitionBuilder, and set the SOAP Action uri to what you want. This means that you can still use the SoapActionEndpointMapping.
    • Use another endpoint mapping, like PayloadRootQNameEndpointMapping. This mapping looks into the message content, not the soap action.

    Finally, I see that you use XStream for marshalling. As mentioned in the docs, XStream does not create XSD-compliant XML. It is an XML serialization engine tailored to java, rather than a full-fledged OXM tool. You're probably better off using one of the other marshallers.

    Comment


    • #3
      I'am new to study Spring-WS 2.x , and found a workaround (Not using <sws:dynamic-wsdl />)

      Code:
        <bean id="MyMath" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
          <property name="serviceName"        value="MyMathService" />
          <property name="portTypeName"       value="MyMathPort" />
          <property name="locationUri"        value="/ws/MyMath" />
          <property name="targetNamespace"    value="http://www.test.me/MyMath/" />
          <property name="schema">
            <bean class="org.springframework.xml.xsd.SimpleXsdSchema">
              <property name="xsd"               value="/WEB-INF/wsdl/MyMath.xsd" />
            </bean>
          </property>
          <property name="soapActions"> <!-- Using this to set soapActions -->
            <props>
              <prop key="add">http://www.test.me/MyMath/add</prop>
              <prop key="minus">http://www.test.me/MyMath/minus</prop>
            </props>
          </property>
        </bean>

      Comment

      Working...
      X