Hi, Phillip,

Have you tried using PolicyReference and classpath? like this:

{code}

<beans xmlns="http://www.springframework.org/schema/beans";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:cxf="http://cxf.apache.org/core";
    xmlns:jaxws="http://cxf.apache.org/jaxws";
    xmlns:p="http://cxf.apache.org/policy";
    xmlns:wsp="http://www.w3.org/ns/ws-policy";
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
            http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
            http://cxf.apache.org/policy 
http://cxf.apache.org/schemas/policy.xsd
            http://www.w3.org/ns/ws-policy 
http://www.w3.org/2007/02/ws-policy.xsd";>


    <import resource="classpath:META-INF/cxf/cxf.xml" />


    <jaxws:endpoint id="...">

        <jaxws:features>
            <p:policies>
                <wsp:PolicyReference URI="classpath:/your.policy" />
            </p:policies>
        </jaxws:features>
   </jaxws:endpoint>

</beans>

{code}


Regards.

Xilai

________________________________
From: Phillip Decker <[email protected]>
Sent: Tuesday, April 18, 2017 2:59:02 AM
To: [email protected]
Subject: policy Reference URIs

Hi all,

I'm fairly new to CXF (started in the last couple months), and I've been
integrating it into a Spring Boot & Integration project (client) with some
success.

The thing is, I've been stuck on a couple issues for the last few days,
and after trial-and-error and stepping through apache-cxf-rt code, I
thought I'd finally admit I have a problem, and come and ask for help:

There's a wsdl for a service I have to integrate with, that has an external
file policyReference in a soap12:operation block. It allegedly works in a
legacy axis application without modification:

It is, literally:
<wsp:Policy>
     <wsp:PolicyReference URI="policy:OurPolicy.xml#messageInput" />
</wsp:Policy>

How do you get this to resolve?  Here's what I tried:
When I copy the contents of "OurPolicy.xml" into the wsdl itself, and get
rid of the bit before the '#', cxf resolves it properly and all is right
with the world.  But I have several dozen wsdls like this, so hand editing
each one this way would be... undesirable.

I've become very familiar with the error "RuntimeException
policy:OurPolicy.xml#messageInput cannot be resoved":

I tried copying the file into the classpath in several different locations
to no avail.
I tried adding a <jaxws:features> to the <jaxws:client> like:
<jaxws:features>
     <p:policies>
          <externalAttachment location="policy.OurPolicy.xml"
     </p:policies>
</jaxws:features>
which didn't work, and I tried "classpath" in place of the "policy:"
scheme, without success.  Also thought maybe I could load it from a
location and give it the policy name, but that didn't work either.  Google
was unhelpful, and the sample code in apache-cxf ws_security uses a policy
which is in the wsdl itself, (the version of the world I got to work
earlier).
I debugged down into the EffectivePolicyImpl class to see if I could find
what the policy was being named, but after tracing this around for another
hour I figured I'd break down and ask...

I'm assuming I need to do _something_ to make the Bus aware of this policy,
in such a way that the wsdls will resolve it, but I could certainly use any
help or suggestions you have.

Thanks in advance,
Phillip

Reply via email to