Custom XML Validator Factory - xsd

I'm getting the following error: src-resolve: Cannot resolve the name 'common:Email' to a(n) 'element declaration' component. when my Spring Integration configuration is loaded. All the marshalling-unmarshalling and xml validation is done via Spring Integration configuration
The problem is that I have in my XSDs some references to external XSD and that's why it's failing.
I was thinking if there's a way to override the Jaxp13ValidatorFactory which is throwing the exception in order to make it able to load the external xsds?

Related

XSLT got the exception in logic apps

When I use the XSLT to transform XML source file then got the below exception in Logic APP. This below URL is avail in the XSLT file.
How to resolve this issue in logic apps?
XSD schema is valid and working fine. At TransformXML place got this issue.
"Code": "InvalidXsltContent", "Message": "An error occurred while
processing map. 'Cannot find a script or an extension object
associated with namespace
'http://schemas.microsoft.com/BizTalk/2003/ScriptNS0'.'",
According to the error message, it seems the logic app can't find the external assembly from the integration account. So could you please check if you have upload the assembly to your integration account ? You can refer to this tutorial to know how to upload the assembly.
By the way, it seems you want to use custom extension in your xslt map. Here I provide two links for your reference:
https://learn.microsoft.com/en-us/biztalk/core/technical-reference/custom-extension-xml-grid-property?redirectedfrom=MSDN
https://blog.vertica.dk/2013/03/20/using-custom-xslt-in-biztalk/

Spring Integration REST service consuming both XML and JSON

I would like to implement the following simple use case with Spring Integration v4.2+:
A REST endpoint is provided to clients, for example (/api/person).
The clients can POST data to this endpoint. The data can be submitted in JSON, XML or Google Protocol Buffers format.
The application accepts the data and saves it to a database table.
I have the following Spring Integration configuration that allows the endpoint to accept JSON data:
<int:channel id="receiveChannel"/>
<http:inbound-channel-adapter id="restInputAdapter"
channel="receiveChannel"
path="/api/person"
request-payload-type="java.util.Map"
supported-methods="POST"/>
<jdbc:outbound-channel-adapter id="jdbcOutputAdapter"
channel="receiveChannel"
data-source="dataSource"
query='INSERT INTO "person" ("first_name", "last_name", "email_address") VALUES (:payload[firstName], :payload[lastName], :payload[email])'/>
This is in a Maven project with Jackson2 on the classpath, which is why no special configuration is required for reading JSON from the request.
However, attempting to post XML data results in the following exception:
org.springframework.messaging.MessagingException: Could not convert request: no suitable HttpMessageConverter found for expected type [java.util.Map] and content type [application/xml]]
I have tried using the message-converters attribute with http:inbound-channel-adapter, specifying Jackson, JAXB and Protocol Buffers converters explicitly but that does not help either.
I know how to do this in a bespoke Spring MVC application with #RestControllers so I am not looking for solutions outside of Spring Integration.
How can the Spring Integration configuration above be tweaked so that the REST endpoint can be made to accept JSON, XML and Google Protocol Buffers at the same time?
It seems that although JSON converts to java.util.Map, XML does not. This is why the seen error.
I created a class:
#XmlRootElement class Person { ... }
and then modified the configuration as follows (only changes shown):
<http:inbound-channel-adapter ...
request-payload-type="Person"
.../>
<jdbc:outbound-channel-adapter ...
query='INSERT INTO "person" ("first_name", "last_name", "email_address") VALUES (:payload.firstName, :payload.lastName, :payload.email)'
.../>
I can now post both XML and JSON data to the endpoint.
Google Protocol Buffers support can now be added using the Protostuff library.

Mule Schema validation when wsdl has embedded xsd

In Mule ESB I want to validate incoming SOAP/XML, using a standard Mule "schema-validation filter".
Something like:
<mulexml:schema-validation-filter schemaLocations="xxx.xsd" name="xxxValidationFilter"/>
However this kind of definition seem to assume that the schema is located in a separate xsd-file, whereas in a lot of cases the schema definition is embedded in the "wsdl:types" element of a wsdl-file.
Is there any way to use the Mule schema-validation-filter to validate against schema's which are embedded in the wsdl (except for copying the schema element definitions out of the
wsdl and into a separate xsd-file).
Mule service element tags which expose the service haave an attribute that can enable validation on the incoming request.
validationEnabled="true"
<cxf:simple-service validationEnabled="true"/>
<cxf:jaxws-service validationEnabled="true"/>
<cxf:proxy-service validationEnabled="true"/>
For more information refer to the following Mule documentation link.
http://www.mulesoft.org/documentation/display/current/Building+Web+Services+with+CXF
Hope this helps.

Spring WS and CXF Binding

I want to implement a webservice client using Spring WS JAXB and CXF.
I use CXF to generate my Stubs from a WSDL file.
This WSDL contains the following schema :
For this schema the only thing that cxf generates is an ObjectFactory and no stub.
I want to use Spring Ws marshalSendAndReceive method to send a request to my service but I don't know how to construct my request object from what was generated with CXF.
Someone can help ?
thx
You don't really need CXF to generate the JAXB types from the WSDL file, JDK comes with a tool called xjc which can do this for you - http://docs.oracle.com/javase/6/docs/technotes/tools/share/xjc.html
Can you try using this and see if the artifacts created with this tool suffice.

XJC fails generating *.java classes

I am trying to generate java classes that describe the web service offered here which belongs to this page. Please mind that I am not convinced that the XML is the one needed to run the following steps!
I save the XML of the API to a file: getcapabilities.xml
I run the following trang command to generate an XSD: java -jar trang.jar getcapabilities.xml getcapabilities.xsd
I get the following files: getcapabilities.xsd, ogc.xsd, wfs.xsd, xlink.xsd, xsi.xsd
I run the following command to generate java classes: xjc getcapabilities.xsd
The following error message is prompted
parsing a schema... [ERROR] no-xsi: The {target namespace} of an attribute declaration must not match 'http://www.w3.org/2001/XMLSchema-instance'.
line 7 of file:xsi.xsd
Failed to parse a schema.
Questions:
Do you get the same error message?
What can I do about it?
Is my approach meant to be successful at all?
You're dealing with an OGC Web Feature Service. There's a couple of peculiarities with that.
Don't generate you schemas with trang, you can get them from OGC: http://schemas.opengis.net/wfs/1.1.0/
You don't really have to compile these schemas on your own, you can get them precompiled from the OGC Schemas and Tools project (JARs are here).
WFS schemas only describe WFS operations - they are kind of container schemas. You'll also have an application profile which describes your features. You can obtain it via the DescribeFeatureType operation: http://data.wien.gv.at/daten/wfs?service=WFS&request=DescribeFeatureType&version=1.1.0
Consider using someting like GeoTools.

Resources