开发者

validating wsdl/schema using cxf

I am having a hard time getting cxf to validate an xml request that my service creates for a 3rd party.

My project uses maven. Here is my project structure

Main Module :

+ S开发者_如何学Goub-Module1 = Application

+ sub-Module2 = Interfaces

In Interfaces, inside src/main/resources I have my wsdl and xsd. so, src/main/resources + mywsdl.wsdl. + myschema.xsd

The interface submodule is listed as a dependency in the Application-sub-module. inside Application sub-module, there is a cxsf file in src/maim/resources.

<jaxws:client name="{myTargerNameSpaceName}port"
    createdFromAPI="true">
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
</jaxws:client>

AND:.

    <jaxws:endpoint name="{myTargetNameSpaceName}port"
    wsdlLocation="/mywsdl.wsdl"
    createdFromAPI="true">
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
</jaxws:endpoint>

I tried changing the "name="{myTargetNameSpaceName}port" to "name="{myEndPointName}port"

But to no anvil.

My application works. But it just do not validate the xml I am producing that has to be consumed by a 3rd party application. I would like to get the validation working, so that any request that I send would be a valid one.

Any suggestions?


Just add @org.apache.cxf.annotations.SchemaValidation annotation on your service implementation class and schema validation will work.


First ensure that the value of the name attribute is {NAMESPACE}PORT_NAME where NAMESPACE is your namespace URI and PORT_NAME is the name of your WSDL port. Without seeing your WSDL, I don't know if you named your WSDL port "port" or if you are just giving a sanitized example.

For example, my WSDL namespace is "http://example.com/services" and the name of my WSDL port element is "myPort", the Spring configuration would look like this

<jaxws:endpoint name="{http://example.com/services}myPort" >
  ...

See "CreatedFromAPI" attribute description in CXF docs

If that doesn't solve your problem, try looking at the wsdl_first example code, upgrading your CXF version, and/or posting your question with test code demonstrating your issue to the CXF user list.


We had similar issues. CXF 2.3.1 fixed the issue for us on incoming messages but not outgoing messages.

https://issues.apache.org/jira/browse/CXF-3233

We work around it by marshaling the messages and validating them within the server before sending them out through the CXF interceptor chain. We validate using org.springframework.xml.validation.XmlValidator.

I'm hoping a future version of CXF will solve this but this is what we do for now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜