公开一个既支持SOAP 1.1又支持SOAP的Web服务。 SOAP 1.2客户端

时间:2015-02-13 21:06:19

标签: web-services soap cxf jax-ws ws-security

目前,我正在使用注释来指定绑定类型,特别指出我的Web服务应该使用SOAP 1.2,但我想修改我的Web服务以接受SOAP 1.1和SOAP 1.2请求。

如果有办法可以帮助你吗?

@WebService
    public interface ExternalService {
        @WebMethod
        public WebTx getTxByTxRefNum(@WebParam(name="txRefNumber") String txRefNumber,
                @WebParam(name="applicationName") String applicationName);
    }

@WebService(endpointInterface = "com.abc.cde.service.ExternalService", serviceName ="ExternalService")
@BindingType(value = SOAP12HTTP_BINDING)
@WSDLDocumentation(value="ABC SOAP 1.2 Services for External Applications", placement = WSDLDocumentation.Placement.TOP)
public class ExternalServiceImpl implements ExternalService {

    @Autowired
    private TxService txService = null;

    public WebTx getTxByTxRefNum(String txRefNumber, String applicationName) {
        try {
            ---
            ---
            Tx tx = this.txService.getTransactionByTxRefNum(txRefNumber, applicationName);
        } catch(RuntimeException runtimeException) {
            ---
            ----
            ---
        }
    }
}

<bean id="externalService" class="com.abc.cde.service.ExternalServiceImpl"/>

<jaxws:endpoint id="ExternalService" implementor="#externalService" address="/ExternalService">
         <jaxws:inInterceptors>
            <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor" />
            <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
                <constructor-arg>
                    <map>
                        <entry key="action" value="UsernameToken" />
                        <entry key="passwordType" value="PasswordText" />
                        <entry key="passwordCallbackRef">
                            <ref bean="serverPasswordCallback" />
                        </entry>
                    </map>
                </constructor-arg>
            </bean>
            <!-- <ref bean="logInbound" />
            <ref bean="logOutbound" /> -->
          </jaxws:inInterceptors>
    </jaxws:endpoint>

1 个答案:

答案 0 :(得分:0)

在CXF中,它是自动的。通过SOAP 1.2公开的端点也将处理1.1请求,并将自动响应1.1响应。