Below is my test-config.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:test="http://www.mulesoft.org/schema/mule/test"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/current/mule-test.xsd ">
...
<flow name="mock_receiver" doc:name="mock_receiver">
...
<test:component>
<test:return-data>error_q</test:return-data>
</test:component>
</flow>
</mule>
Below error shown in Eclipse IDE on line :
Multiple annotations found at this line:
- schema_reference.4: Failed to read schema document 'http://www.mulesoft.org/schema/mule/test/current/mule-test.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
- cvc-complex-type.2.4.a: Invalid content was found starting with element 'test:component'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/
schema/mule/core":response}' is expected.
And getting below error on deploying application to Mule standalone server:
ERROR [24 May 2013 01:59:25,186] [WrapperListener_start_runner] (DispatchingLogger:365) - null
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'test:component'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-outbound-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor, "http://www.mulesoft.org/schema/mule/core":response}' is expected.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
My bad. There was 2 files with the name test-config.xml and I was doing changes in the wrong one.
Related
I am trying to add custom validation against a generated request object for incoming JSON payload using the javax.validation framework and openapi-generator-maven-plugin in Mule ESB.
I am following the below mulesoft documentation :
https://docs.mulesoft.com/mule-runtime/3.9/building-a-custom-validator
I have added the below custom validation :
<validation:custom-validator doc:name="Validation" class="com.poltu.validation.CustomValidator" />
But when I amtrying to run the application ,it fails with the below message :
Invalid content was found starting with element 'validation:custom-validator'. One of '{"http://www.mulesoft.org/schema/mule/core":abstract-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-message-processor}' is expected.
Edit :
below is the xml configuration that I am now using :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:validation="http://www.mulesoft.org/schema/mule/validation"
xmlns:xml-module="http://www.mulesoft.org/schema/mule/xml-module"
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:java="http://www.mulesoft.org/schema/mule/java"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:db="http://www.mulesoft.org/schema/mule/db"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/json
http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/db
http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/ee/core
http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/java
http://www.mulesoft.org/schema/mule/java/current/mule-java.xsd
http://www.mulesoft.org/schema/mule/xml-module
http://www.mulesoft.org/schema/mule/xml-module/current/mule-xml-module.xsd
http://www.mulesoft.org/schema/mule/validation
http://www.mulesoft.org/schema/mule/validation/current/mule-validation.xsd">
<db:config name="Database_Config" doc:name="Database Config"
doc:id="d31ea473-7b58-4d28-83b3-bed7e0bebf2c" >
<db:oracle-connection host="localhost" user="system" password="system"
instance="xe" />
</db:config>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener
config" doc:id="78fddb86-0942-4ccf-a300-2d721291c964" basePath="/emp_service"
>
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="mule1Flow" doc:id="246fb555-ea4b-4b9f-bf2c-a332dc3a0ea1" >
<http:listener doc:name="Add_emp_Listener" doc:id="a9d8ff2a-00a7-4759-
8c0f-c53b9211e0e9" config-ref="HTTP_Listener_config" path="add_emp"
allowedMethods="POST"/>
<validation:custom-validator doc:name="validation"
class="com.poltu.validation.CustomValidator" />
<db:insert doc:name="Insert" doc:id="d44b5680-ae0a-4e97-8c91-
9baba4039e7e" config-ref="Database_Config">
<db:sql ><![CDATA[insert into emp_details
values(:emp_id,:emp_name,:emp_status)]]></db:sql>
<db:input-parameters ><![CDATA[#[{
"emp_id": payload.emp_id,
"emp_name" : payload.emp_name,
"emp_status" : payload.emp_status
}]]]></db:input-parameters>
</db:insert>
<ee:transform doc:name="Transform Message" doc:id="7e7be7f4-c2fc-43f9-
8b76-bf63bf8ac51b" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
"status":"OK",
"response":"Created re bhaii...."
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="647043ee-5a28-414e-898e-
dce291114c2c" message="response payload is -- #[payload.response]"/>
</flow>
</mule>
The documentation that you are using is for Mule 3.9. That method is not compatible with Mule 4. To create a custom validator in Mule 4 you need to create a Mule Extension with the Mule SDK for Java. Follow the instructions to create the module. Once your module builds, add a validator operation as described at https://docs.mulesoft.com/mule-runtime/4.3/migration-module-validation#custom_validator
I tried using FTP connector and FileZilla FTP server (xampp).
Here is my flow code and output. In case when I'm using SFTP I'm getting output as "connection is closed by foreign host".
Configuration XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd">
<file:connector name="FileRead" readFromDirectory="D:\Data\input" autoDelete="false" streaming="true" validateConnections="true" doc:name="File"/>
<ftp:connector name="FTP" pollingFrequency="1000" validateConnections="true" outputPattern="output.json" doc:name="FTP"/>
<flow name="ftpFlow">
<file:inbound-endpoint path="D:\Data\input" connector-ref="FileRead" pollingFrequency="100000" responseTimeout="10000" doc:name="File"/>
<ftp:outbound-endpoint host="127.0.0.1" port="14147" passive="true" responseTimeout="10000" doc:name="FTP" connector-ref="FTP" outputPattern="output.json" password="kamal" path="/" user="kamal"/>
</flow>
</mule>
Console Output:
INFO 2018-03-01 13:00:07,218 [[ftp].FileRead.receiver.01] org.mule.transport.file.FileMessageReceiver: Lock obtained on file: D:\Data\input\example.json
INFO 2018-03-01 13:00:07,300 [[ftp].FTP.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Initialising: 'FTP.dispatcher.145993108'. Object is: FtpMessageDispatcher
INFO 2018-03-01 13:00:07,305 [[ftp].FTP.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager: Starting: 'FTP.dispatcher.145993108'. Object is: FtpMessageDispatcher
ERROR 2018-03-01 13:01:12,866 [[ftp].FTP.dispatcher.01] org.mule.retry.notifiers.ConnectNotifier: Failed to connect/reconnect: EEFtpConnector
{
name=FTP
lifecycle=start
this=608b1fd2
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[ftp]
serviceOverrides=<none>
}
. Root Exception was: Could not parse response code.
Server Reply: FZS
Listening port of File Zilla was 21. Port 14147 is administration port.
Use the little small groovy script provided in that.This should work .I just tested this and working as expected .Deleting can be done by autoDelete attribute or fileAge .Please let me know if this helps
<flow name="ftptestFlow">
<ftp:inbound-endpoint host="hostname" port="port" path="path/filename" user="userid" password="password" responseTimeout="10000" doc:name="FTP"/>
<set-variable variableName="fileName" value="fileName" doc:name="fileName"/>
<scripting:component doc:name="getFile">
<scripting:script engine="Groovy"><![CDATA[new File(flowVars.fileName).getText('UTF-8')]]></scripting:script>
</scripting:component>
<file:outbound-endpoint path="path" outputPattern="filename" responseTimeout="10000" doc:name="File"/>
</flow>
I'm getting an error:
Caused by: org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 44; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aws-messaging:sqs-async-client'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1911)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.emptyElement(XMLSchemaValidator.java:760)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:351)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
at com.sun.org.apache.xerces.internal.parsers.XML11Confin.parse(XML11Configuration.java:770)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:339)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
I'm using the following xsd's:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aws-messaging="http://www.springframework.org/schema/c"
xmlns:int-aws="http://www.springframework.org/schema/c"
xmlns:aws-context="http://www.springframework.org/schema/p"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd"
default-lazy-init="true">
<description>
Connects to SQS, fetches the compressed payload and sends to
uncompress channel
Step 1 of the flow
</description>
<aws-messaging:sqs-async-client id="sqs"/>
<aws-context:context-credentials>
<aws-context:simple-credentials access-key="${aws.accesskey}"
secret-key="${aws.secretkey}"/>
</aws-context:context-credentials>
This used to work before. I used this as a template: https://github.com/spring-projects/spring-integration-aws/blob/master/src/test/java/org/springframework/integration/aws/config/xml/SqsMessageHandlerParserTests-context.xml
Can you please help? Did something change?
Look , what you have for namespace prefixes:
xmlns:aws-messaging="http://www.springframework.org/schema/c"
xmlns:int-aws="http://www.springframework.org/schema/c"
xmlns:aws-context="http://www.springframework.org/schema/c"
And what has to be:
xmlns:int-aws="http://www.springframework.org/schema/integration/aws"
xmlns:aws-messaging="http://www.springframework.org/schema/cloud/aws/messaging"
xmlns:aws-context="http://www.springframework.org/schema/cloud/aws/context"
Plus you have to add their schemaLocations as well:
http://www.springframework.org/schema/integration/aws http://www.springframework.org/schema/integration/aws/spring-integration-aws.xsd
http://www.springframework.org/schema/cloud/aws/messaging http://www.springframework.org/schema/cloud/aws/messaging/spring-cloud-aws-messaging.xsd
http://www.springframework.org/schema/cloud/aws/context http://www.springframework.org/schema/cloud/aws/context/spring-cloud-aws-context.xsd
According to XSD file, SoftLayer_Product_PackageObjectFilter receive a categories parameter that is a tns:SoftLayer_Product_Item_CategoryObjectFilter.
SoftLayer_Product_Item_CategoryObjectFilter accepts categoryCode that is a SoftLayer_Utility_ObjectFilter_Operation, so a filter to get only categories with categoryCode 'guest_disk0' would be:
object_filter = {
'categories': {
'categoryCode': {
'operation': 'guest_disk0'
}
}
}
When I call with this filter on header, I'm receiving SoftLayer_Exception_Public
Here is my SOAP request
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.service.softlayer.com/soap/v3.1/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<authenticate>
<username>USER</username>
<apiKey>KEY</apiKey>
</authenticate>
<tns:SoftLayer_Product_PackageObjectFilter>
<categories>
<categoryCode>
<operation>guest_disk0</operation>
</categoryCode>
</categories>
</tns:SoftLayer_Product_PackageObjectFilter>
<tns:SoftLayer_ObjectMask>
<mask>mask[categoryCode,name]</mask>
</tns:SoftLayer_ObjectMask>
<SoftLayer_Product_PackageInitParameters>
<id>46</id>
</SoftLayer_Product_PackageInitParameters>
</env:Header>
<env:Body>
<tns:getCategories></tns:getCategories>
</env:Body>
</env:Envelope>
Following the exact same idea, but filtering activeRamItems for keyName we can perfectly use the filter
object_filter = {
'activeRamItems': {
'keyName': {
'operation': 'RAM_12_GB'
}
}
}
The SOAP request is exact the same used for categories, just changing the filter
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://api.service.softlayer.com/soap/v3.1/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<authenticate>
<username>USER</username>
<apiKey>KEY</apiKey>
</authenticate>
<tns:SoftLayer_Product_PackageObjectFilter>
<activeRamItems>
<keyName>
<operation>RAM_12_GB</operation>
</keyName>
</activeRamItems>
</tns:SoftLayer_Product_PackageObjectFilter>
<tns:SoftLayer_ObjectMask>
<mask>mask[id,keyName]</mask>
</tns:SoftLayer_ObjectMask>
<SoftLayer_Product_PackageInitParameters>
<id>46</id>
</SoftLayer_Product_PackageInitParameters>
</env:Header>
<env:Body>
<tns:getActiveRamItems></tns:getActiveRamItems>
</env:Body>
</env:Envelope>
I do REALLY believe this is an API error, but as the SoftLayer procedure is open a question on stack overflow for any API related issues, I'm opening here
When I run this:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http="http://www.mulesource.org/schema/mule/http/2.2"
xmlns:https="http://www.mulesource.org/schema/mule/https/2.2"
xsi:schemaLocation="
http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd
http://www.mulesource.org/schema/mule/https/2.2 http://www.mulesource.org/schema/mule/https/2.2/mule-https.xsd
http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd">
<model>
<service name="ConnectToHTTPS">
<inbound>
<http:inbound-endpoint host="localhost"
port="9000"
synchronous="true"/>
</inbound>
<outbound>
<chaining-router>
<outbound-endpoint address="https://localhost"
synchronous="true"/>
</chaining-router>
</outbound>
</service>
</model>
</mule>
I get this:
...
ERROR 2011-07-05 13:06:28,826 [main] org.mule.MuleServer:
********************************************************************************
Message : Failed to invoke lifecycle phase "initialise" on object: HttpsConnector{this=1efe475, started=false, initialised=false, name='connector.https.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[https], serviceOverrides=null}
Type : org.mule.api.lifecycle.LifecycleException
Code : MULE_ERROR-70228
JavaDoc : http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/lifecycle/LifecycleException.html
********************************************************************************
Exception stack is:
1. The Key password cannot be null (java.lang.IllegalArgumentException)
org.mule.api.security.tls.TlsConfiguration:290 (null)
2. Failed to invoke lifecycle phase "initialise" on object: HttpsConnector{this=1efe475, started=false, initialised=false, name='connector.https.0', disposed=false, numberOfConcurrentTransactedReceivers=4, createMultipleTransactedReceivers=true, connected=false, supportedProtocols=[https], serviceOverrides=null} (org.mule.api.lifecycle.LifecycleException)
org.mule.lifecycle.DefaultLifecyclePhase:277 (http://www.mulesource.org/docs/site/current2/apidocs/org/mule/api/lifecycle/LifecycleException.html)
********************************************************************************
...
You need to explicitly configure the HTTPS connector with a client keystore so you can make outbound HTTPS calls. This is explained here (free registration required to read this doc).
In essence, it boils down to this:
<https:connector name="httpConnector">
<https:tls-client path="clientKeystore" storePassword="mulepassword"/>
</https:connector>