package web service client together with another service websphere

时间:2016-04-15 15:06:06

标签: websphere jax-ws

I have two legacy web services running on WebSphere 8.5.5. Call them serviceOne and serviceTwo. ServiceOne is invoking serviceTwo. To do that, serviceOne ear contains the serviceTwo client. We have a requirement to authenticate serviceTwo. We are trying to use PolicySets/Bindings to configure the username and password and have the serviceTwoClient pass them to the serviceTwo provider.

The way they are packaged right now is:

 -- serviceOne.ear
 |
 -- serviceOneEJB.jar
 |  |
 |   -- serviceTwoClient.jar 
 -- serviceOneWeb.war

The problem we have is with packaging the serviceOne ear in order for WebSphere to detect the serviceTwo client within it and list it under Services -> Client Providers so we can attach the PolicySet.

With the current packaging scheme, the serviceTwo client is not detected.

So I tried pulling the serviceTwoClient.jar at the root level of the ear file. This doesn't help, the serviceTwo client is not listed under Client Providers.

Then I tried to package the serviceTwo client as a war file and pack it at the top level of the ear. This helps, the client gets listed in the client providers on the admin console; but I have two alternatives: - leave the old jar file packed with the serviceOneEJB. In this case the service invocation works fine but the policyBindings do not send the auth information with the request. I guess that's because the actual call goes through the jar and does not invoke the war, and the policyBinding is not invoked. - remove the old jar from the serviceOneEJB.jar. In this case the service call fails because application context is not loaded properly (is actually null).

Any help/ideas are greatly appreciated.

1 个答案:

答案 0 :(得分:0)

经过一番挖掘,我发现了解决方案;将以下内容添加到serviceOneWeb应用程序的web.xml中:

<service-ref>
        <service-ref-name>serviceTwo_Service</service-ref-name>
        <service-interface>ServiceTwo class name</service-interface>
        <wsdl-file>ServiceTwo.wsdl</wsdl-file>
        <service-qname xmlns:pfx="service_two_  url">pfx:ServiceTwo</service-qname>
  <port-component-ref>
        <service-endpoint-interface>ServiceTwoClient_Service class</service-endpoint-interface>
        <enable-mtom>false</enable-mtom>
  </port-component-ref>
  </service-ref>


<security-constraint>
    <display-name>SERVICE_ACCESS</display-name>
    <web-resource-collection>
            <web-resource-name>SERVICE_URLS</web-resource-name>
            <url-pattern>/*</url-pattern>
            <http-method>GET</http-method>
            <http-method>PUT</http-method>
            <http-method>HEAD</http-method>
            <http-method>TRACE</http-method>
            <http-method>POST</http-method>
            <http-method>DELETE</http-method>
            <http-method>OPTIONS</http-method>
    </web-resource-collection>
    <auth-constraint>
            <role-name>SERVICE_TWO_USER</role-name>
    </auth-constraint>
</security-constraint>
<login-config>
            <auth-method>BASIC</auth-method>
</login-config>
<security-role>
            <role-name>SERVICE_TWO_USER</role-name>
</security-role>