简体   繁体   中英

Spring WS force SOAP endpoint operation name

I am implementing a SOAP WS with spring, I have my XSDs, then I add my endpoints with annotations such as:

@Endpoint
public class StuffRequestEndpoint {

    @PayloadRoot(namespace = "urn:mycomp-com/xyz/ws/msg", localPart = "StuffRequest")
    public
    @ResponsePayload
    StuffResponse requestStuff(@RequestPayload StuffRequest request) {

The problem I have is that the produced WSDL has a funny operation name:

    <wsdl:operation name="Stuff">
        <soap:operation soapAction=""/>
        <wsdl:input name="StuffRequest">
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="StuffResponse">
            <soap:body use="literal"/>
        </wsdl:output>

How could I override the produced operation name?

Thanks.

I don't see that you have done anything on the matter. Hence let's try to follow with the JavaDocs for DefaultWsdl11Definition :

/**
 * Sets the SOAP Actions for this binding. Keys are {@link javax.wsdl.BindingOperation#getName() binding operation
 * names}; values are {@link javax.wsdl.extensions.soap.SOAPOperation#getSoapActionURI() SOAP Action URIs}.
 *
 * @param soapActions the soap
 */
public void setSoapActions(Properties soapActions) {
    soapProvider.setSoapActions(soapActions);
}

Where the usage is like ( Soap12Provider ):

protected void populateSoapOperation(SOAP12Operation soapOperation, BindingOperation bindingOperation)
        throws WSDLException {
    String bindingOperationName = bindingOperation.getName();
    String soapAction = getSoapActions().getProperty(bindingOperationName, "");
    soapOperation.setSoapActionURI(soapAction);
}

That's way you see there an empty string.

Well I see this is pretty old and I too do not have a direct answer, what I did was basically renaming the object to what I want the action be named like.

Since Spring-WS looks at the xsd and if it sees name with Request/Response suffix it creates an action with such name, eg object GetListOfCitiesRequest would be GetListOfCities action. In your case that could be something like this in XSD

<xs:element name="GetListOfCitiesRequest">

which would then appear like this wsdl generated by spring-ws

<wsdl:operation name="GetListOfCities">
    <soap:operation soapAction=""/>
    <wsdl:input name="GetListOfCitiesRequest">
        <soap:body use="literal"/>
    </wsdl:input>
</wsdl:operation>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM