I want to extract complex XML data to SQL server. Already tried SSIS package with no success. What do I change in my code to desired output
I have tried below T-SQL
DECLARE #xmlData XML
SET #xmlData = (
SELECT CONVERT(XML, BulkColumn) AS BulkColumn
FROM OPENROWSET(BULK 'C:..\NewTextDocument.xml', SINGLE_BLOB) as x
)
SELECT
ref.value('FilterID[1]', 'int') AS FilterID ,
ref.value('Name[1]', 'NVARCHAR (255)') AS Name ,
ref.value('Code[1]', 'NVARCHAR (255)') AS Code ,
ref.value('Department[1]', 'NVARCHAR (255)') AS Department
FROM #xmlData.nodes('DataSet/Export/Test')
xmlData( ref )
My XML is in below format
<?xml version="1.0" encoding="ISO-8859-1"?>
<DataSet>
<xs:schema id="Export" xmlns:msdata="urn:schemas-microsoft-com:xml-
msdata" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="">
<xs:element msdata:Locale="" msdata:IsDataSet="true" name="Export">
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="0">
<xs:element name="Test">
<xs:complexType>
<xs:sequence>
<xs:element name="FilterID" minOccurs="0" type="xs:int"/>
<xs:element name="Name" minOccurs="0" type="xs:string"/>
<xs:element name="Code" minOccurs="0" type="xs:string"/>
<xs:element name="Department" minOccurs="0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<Export>
<Test diffgr:id="Test1" msdata:rowOrder="0">
<FilterID>1</FilterID>
<Name>John</Name>
<Code>123</Code>
<Department>Science</Department>
</Test>
<Test diffgr:id="Test2" msdata:rowOrder="1">
<FilterID>2</FilterID>
<Name>Jay</Name>
<Code>321</Code>
<Department>Maths</Department>
</Test>
</Export>
Expected Output
FilterID | Name | Code | Department
------------------------------------
1 | John | 123 | Science
2 | Jay | 321 | Maths
Resolved, I was able to query data by modifying from clause in above code
FROM #xmlData.nodes('DataSet/Export/Test')
to
FROM #xmlData.nodes('//Export/Test')
Related
I have an XML file that looks like this:
<?xml version="1.0" encoding = "utf-8"?>
<CIM CIMVERSION="2.0" DTDVERSION="2.0">
<MESSAGE ID="1111" PROTOCOLVERSION="1.0">
<SIMPLEREQ>
<VALUE.NAMEDINSTANCE>
<INSTANCENAME CLASSNAME="DCIM_ControllerView">
<KEYBINDING NAME="InstanceID">
<KEYVALUE VALUETYPE="string">RAID.Integrated.1-1</KEYVALUE>
</KEYBINDING>
</INSTANCENAME>
<INSTANCE CLASSNAME="DCIM_ControllerView">
<PROPERTY NAME="LastUpdateTime" TYPE="string">
<VALUE>20170223172914.000000+000</VALUE>
<DisplayValue>2017-02-23T17:29:14</DisplayValue>
</PROPERTY>
<PROPERTY NAME="LastSystemInventoryTime" TYPE="string">
<VALUE>20170223172914.000000+000</VALUE>
<DisplayValue>2017-02-23T17:29:14</DisplayValue>
</PROPERTY>
<PROPERTY NAME="RealtimeCapability" TYPE="uint32">
<VALUE>6</VALUE>
<DisplayValue>Capable</DisplayValue>
</PROPERTY>
<PROPERTY NAME="SupportControllerBootMode" TYPE="uint8">
<VALUE>1</VALUE>
<DisplayValue>Supported</DisplayValue>
</PROPERTY>
<PROPERTY NAME="SupportEnhancedAutoForeignImport" TYPE="uint8">
<VALUE>1</VALUE>
<DisplayValue>Supported</DisplayValue>
</PROPERTY>
<PROPERTY NAME="MaxAvailablePCILinkSpeed" TYPE="string">
<VALUE>Generation 3</VALUE>
<DisplayValue>Generation 3</DisplayValue>
</PROPERTY>
<PROPERTY NAME="MaxPossiblePCILinkSpeed" TYPE="string">
<VALUE>Generation 3</VALUE>
<DisplayValue>Generation 3</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PatrolReadState" TYPE="uint8">
<VALUE>1</VALUE>
<DisplayValue>Stopped</DisplayValue>
</PROPERTY>
<PROPERTY NAME="DriverVersion" TYPE="string">
<DisplayValue>Not Applicable</DisplayValue>
</PROPERTY>
<PROPERTY NAME="CacheSizeInMB" TYPE="uint32">
<VALUE>0</VALUE>
<DisplayValue>0 MB</DisplayValue>
</PROPERTY>
<PROPERTY NAME="SupportRAID10UnevenSpans" TYPE="uint8">
<VALUE>1</VALUE>
<DisplayValue>Supported</DisplayValue>
</PROPERTY>
<PROPERTY NAME="T10PICapability" TYPE="uint8">
<VALUE>1</VALUE>
<DisplayValue>Supported</DisplayValue>
</PROPERTY>
<PROPERTY NAME="SlicedVDCapability" TYPE="uint8">
<VALUE>1</VALUE>
<DisplayValue>Sliced Virtual Disk creation supported</DisplayValue>
</PROPERTY>
<PROPERTY NAME="CachecadeCapability" TYPE="uint8">
<VALUE>0</VALUE>
<DisplayValue>Cachecade Virtual Disk not supported</DisplayValue>
</PROPERTY>
<PROPERTY NAME="KeyID" TYPE="string">
<DisplayValue/>
</PROPERTY>
<PROPERTY NAME="EncryptionCapability" TYPE="uint8">
<VALUE>1</VALUE>
<DisplayValue>Local Key Management Capable</DisplayValue>
</PROPERTY>
<PROPERTY NAME="EncryptionMode" TYPE="uint8">
<VALUE>0</VALUE>
<DisplayValue>None</DisplayValue>
</PROPERTY>
<PROPERTY NAME="SecurityStatus" TYPE="uint32">
<VALUE>1</VALUE>
<DisplayValue>Encryption Capable</DisplayValue>
</PROPERTY>
<PROPERTY NAME="SASAddress" TYPE="string">
<VALUE>1111</VALUE>
<DisplayValue>1111</DisplayValue>
</PROPERTY>
<PROPERTY NAME="ProductName" TYPE="string">
<VALUE>PERC Mini</VALUE>
<DisplayValue>PERC Mini</DisplayValue>
</PROPERTY>
<PROPERTY NAME="DeviceCardSlotType" TYPE="string">
<VALUE>Unknown</VALUE>
<DisplayValue>Unknown</DisplayValue>
</PROPERTY>
<PROPERTY NAME="DeviceCardSlotLength" TYPE="uint8">
<VALUE>2</VALUE>
<DisplayValue>Unknown</DisplayValue>
</PROPERTY>
<PROPERTY NAME="DeviceCardDataBusWidth" TYPE="string">
<VALUE>Unknown</VALUE>
<DisplayValue>Unknown</DisplayValue>
</PROPERTY>
<PROPERTY NAME="DeviceCardManufacturer" TYPE="string">
<VALUE>DELL</VALUE>
<DisplayValue>DELL</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCISubDeviceID" TYPE="string">
<VALUE>1111</VALUE>
<DisplayValue>1F47</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCIDeviceID" TYPE="string">
<VALUE>1</VALUE>
<DisplayValue>1</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCISubVendorID" TYPE="string">
<VALUE>1</VALUE>
<DisplayValue>1</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCIVendorID" TYPE="string">
<VALUE>1</VALUE>
<DisplayValue>1</DisplayValue>
</PROPERTY>
<PROPERTY NAME="Function" TYPE="string">
<VALUE>0</VALUE>
<DisplayValue>0</DisplayValue>
</PROPERTY>
<PROPERTY NAME="Device" TYPE="string">
<VALUE>0</VALUE>
<DisplayValue>0</DisplayValue>
</PROPERTY>
<PROPERTY NAME="Bus" TYPE="string">
<VALUE>2</VALUE>
<DisplayValue>2</DisplayValue>
</PROPERTY>
<PROPERTY NAME="ControllerFirmwareVersion" TYPE="string">
<VALUE>00.00.00.00</VALUE>
<DisplayValue>00.00.00.00</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCISlot" TYPE="uint8">
<VALUE>0</VALUE>
<DisplayValue>0</DisplayValue>
</PROPERTY>
<PROPERTY NAME="RollupStatus" TYPE="uint32">
<VALUE>1</VALUE>
<DisplayValue>OK</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PrimaryStatus" TYPE="uint32">
<VALUE>1</VALUE>
<DisplayValue>OK</DisplayValue>
</PROPERTY>
<PROPERTY NAME="DeviceDescription" TYPE="string">
<VALUE>Integrated RAID Controller 1</VALUE>
<DisplayValue>Integrated RAID Controller 1</DisplayValue>
</PROPERTY>
<PROPERTY NAME="FQDD" TYPE="string">
<VALUE>RAID.Integrated.1-1</VALUE>
<DisplayValue>RAID.Integrated.1-1</DisplayValue>
</PROPERTY>
<PROPERTY NAME="InstanceID" TYPE="string">
<VALUE>RAID.Integrated.1-1</VALUE>
<DisplayValue>RAID.Integrated.1-1</DisplayValue>
</PROPERTY>
</INSTANCE>
</VALUE.NAMEDINSTANCE>
</SIMPLEREQ>
</MESSAGE>
</CIM>
I am able to bring into SQL and read as an XML object.
Currently,I bring the XML text in a single string using SSIS.
After the file is read in SSIS, it bring it into my database into a staging table like this:
Now that the files can be brought into my staging table, I want to parse them into specific columns using a trigger.
Please note that the XML string are in UTF-8.
This data comes from a Dell Hardware inventory XML file.
Their document outlines their XML schema in this diagram:
I need to get that XML data into a column format that mimics that diagram. So the headers would be:
CIM | Messgae | Classname | InstanceID | PropertyName | Value | DisplayValue
These columns would contain their respective data in the XML
Also, as I mentioned it is into utf-8 format.
To read it as an XML object in SQL, I am using this code:
declare #XML xml
set #XML = (SELECT Top 1 REPLACE([XML], 'utf-8', 'utf-16')FROM [StagingTable])
SELECT #XML
Also, I have multiple instances of INSTANCENAME, with more sets INSTANCE, PROPERTY, VALUE, DISPLAYVALUE, etc.
Here is the XML schema as per the Dell Document:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://schemas.dell.com/HWinventory/1/0/events"
elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:evt="http://schemas.dell.com/HWinventory/1/0/events">
<xs:element name="CIM">
<xs:complexType>
<xs:sequence>
<xs:element name="MESSAGE">
<xs:complexType>
<xs:sequence>
<xs:element name="SIMPLEREQ">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="VALUE.NAMEDINSTANCE">
<xs:complexType>
<xs:sequence>
<xs:element name="INSTANCENAME">
<xs:complexType>
<xs:sequence>
<xs:element name="KEYBINDING">
<xs:complexType>
<xs:sequence>
<xs:element name="KEYVALUE">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="VALUETYPE" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="NAME" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="CLASSNAME" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="INSTANCE">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="PROPERTY.ARRAY">
<xs:complexType>
<xs:sequence>
<xs:element name="VALUE.ARRAY">
<xs:complexType>
<xs:sequence>
<xs:element name="VALUE" type="xs:string" />
<xs:element name="DisplayValue" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="NAME" type="xs:string" use="required" />
<xs:attribute name="TYPE" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="PROPERTY">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="VALUE" type="xs:string" />
<xs:element name="DisplayValue" type="xs:string" />
</xs:sequence>
<xs:attribute name="NAME" type="xs:string" use="required" />
<xs:attribute name="TYPE" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="CLASSNAME" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="ID" type="xs:int" use="required" />
<xs:attribute name="PROTOCOLVERSION" type="xs:decimal" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
The following query will retrieve various data from your XML. It won't be exactly what you need, but it should give you a template for any value you might want to pull out:
DECLARE #xml XML=
N'<CIM CIMVERSION="2.0" DTDVERSION="2.0">
<MESSAGE ID="4711" PROTOCOLVERSION="1.0">
<SIMPLEREQ>
<VALUE.NAMEDINSTANCE xmlns:fo="http://www.w3.org/1999/XSL/Format">
<INSTANCENAME CLASSNAME="DCIM_ControllerView">
<KEYBINDING NAME="InstanceID">
<KEYVALUE VALUETYPE="string">RAID.Slot.1-1</KEYVALUE>
</KEYBINDING>
</INSTANCENAME>
<INSTANCE CLASSNAME="DCIM_ControllerView">
<PROPERTY NAME="DriverVersion" TYPE="string">
<DisplayValue />
</PROPERTY>
<PROPERTY NAME="KeyID" TYPE="string">
<DisplayValue />
</PROPERTY>
<PROPERTY NAME="SASAddress" TYPE="string">
<VALUE>5782BCB00C577600</VALUE>
<DisplayValue>5782BCB00C577600</DisplayValue>
</PROPERTY>
<PROPERTY NAME="ProductName" TYPE="string">
<VALUE>PERC H310 Adapter</VALUE>
<DisplayValue>PERC H310 Adapter</DisplayValue>
</PROPERTY>
<PROPERTY NAME="DeviceCardSlotType" TYPE="string">
<VALUE>PCI Express x8</VALUE>
<DisplayValue>PCI Express x8</DisplayValue>
</PROPERTY>
<PROPERTY NAME="DeviceCardManufacturer" TYPE="string">
<VALUE>DELL</VALUE>
<DisplayValue>DELL</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCISubDeviceID" TYPE="string">
<VALUE>1F4E</VALUE>
<DisplayValue>1F4E</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCIDeviceID" TYPE="string">
<VALUE>73</VALUE>
<DisplayValue>73</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCISubVendorID" TYPE="string">
<VALUE>1028</VALUE>
<DisplayValue>1028</DisplayValue>
</PROPERTY>
<PROPERTY NAME="PCIVendorID" TYPE="string">
<VALUE>1000</VALUE>
<DisplayValue>1000</DisplayValue>
</PROPERTY>
<PROPERTY NAME="Function" TYPE="string">
<VALUE>0</VALUE>
<DisplayValue>0</DisplayValue>
</PROPERTY>
<PROPERTY NAME="Device" TYPE="string">
<VALUE>0</VALUE>
<DisplayValue>0</DisplayValue>
</PROPERTY>
<PROPERTY NAME="Bus" TYPE="string">
<VALUE>1</VALUE>
<DisplayValue>1</DisplayValue>
</PROPERTY>
<PROPERTY NAME="ControllerFirmwareVersion" TYPE="string">
<VALUE>20.10.1-0066</VALUE>
<DisplayValue>20.10.1-0066</DisplayValue>
</PROPERTY>
</INSTANCE>
</VALUE.NAMEDINSTANCE>
</SIMPLEREQ>
</MESSAGE>
</CIM>';
--The query
SELECT #xml.value(N'(/CIM/#CIMVERSION)[1]',N'nvarchar(max)') AS CIM_version
,#xml.value(N'(/CIM/MESSAGE/#ID)[1]',N'nvarchar(max)') AS Message_Id
,#xml.value(N'(/CIM/MESSAGE/SIMPLEREQ/VALUE.NAMEDINSTANCE/INSTANCENAME/KEYBINDING/KEYVALUE/text())[1]',N'nvarchar(max)') AS Keybinding_Value
,prp.value(N'#NAME',N'nvarchar(max)') AS Prop_Name
,prp.value(N'(VALUE/text())[1]',N'nvarchar(max)') AS Prop_Value
,prp.value(N'(DisplayValue/text())[1]',N'nvarchar(max)') AS Prop_DisplayValue
FROM #xml.nodes(N'/CIM/MESSAGE/SIMPLEREQ/VALUE.NAMEDINSTANCE/INSTANCE/PROPERTY') AS A(prp);
The result
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| CIM_version | Message_Id | Keybinding_Value | Prop_Name | Prop_Value | Prop_DisplayValue |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | DriverVersion | NULL | NULL |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | KeyID | NULL | NULL |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | SASAddress | 5782BCB00C577600 | 5782BCB00C577600 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | ProductName | PERC H310 Adapter | PERC H310 Adapter |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | DeviceCardSlotType | PCI Express x8 | PCI Express x8 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | DeviceCardManufacturer | DELL | DELL |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | PCISubDeviceID | 1F4E | 1F4E |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | PCIDeviceID | 73 | 73 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | PCISubVendorID | 1028 | 1028 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | PCIVendorID | 1000 | 1000 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | Function | 0 | 0 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | Device | 0 | 0 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | Bus | 1 | 1 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
| 2.0 | 4711 | RAID.Slot.1-1 | ControllerFirmwareVersion | 20.10.1-0066 | 20.10.1-0066 |
+-------------+------------+------------------+---------------------------+-------------------+-------------------+
i created a sample apache cxf SOAP webservices, following the tutorial here
i'm able to run on tomcat 9 via eclipse neon and access it at http://localhost:8080/camel-example-reportincident/webservices/incident?wsdl.
i installed and started it on websphere, but i can't access it on the same url. i also tried all other ports listed in default host alias.
my maven libraries:
here is my wsdl:
<?xml version="1.0" encoding="ISO-8859-1"?> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://reportincident.example.camel.apache.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://reportincident.example.camel.apache.org">
<!-- Type definitions for input- and output parameters for webservice
--> <wsdl:types> <xs:schema targetNamespace="http://reportincident.example.camel.apache.org"> <xs:element name="inputReportIncident">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="incidentId" />
<xs:element type="xs:string" name="incidentDate" />
<xs:element type="xs:string" name="givenName" />
<xs:element type="xs:string" name="familyName" />
<xs:element type="xs:string" name="summary" />
<xs:element type="xs:string" name="details" />
<xs:element type="xs:string" name="email" />
<xs:element type="xs:string" name="phone" />
</xs:sequence>
</xs:complexType> </xs:element> <xs:element name="outputReportIncident">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="code" />
</xs:sequence>
</xs:complexType> </xs:element> </xs:schema> </wsdl:types>
<!-- Message definitions for input and output --> <wsdl:message name="inputReportIncident"> <wsdl:part name="parameters" element="tns:inputReportIncident" /> </wsdl:message> <wsdl:message name="outputReportIncident"> <wsdl:part name="parameters" element="tns:outputReportIncident" /> </wsdl:message>
<!-- Port (interface) definitions --> <wsdl:portType name="ReportIncidentEndpoint"> <wsdl:operation name="ReportIncident"> <wsdl:input message="tns:inputReportIncident" /> <wsdl:output message="tns:outputReportIncident" /> </wsdl:operation> </wsdl:portType>
<!-- Port bindings to transports and encoding - HTTP, document literal encoding is used --> <wsdl:binding name="ReportIncidentBinding" type="tns:ReportIncidentEndpoint"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="ReportIncident"> <soap:operation
soapAction="http://reportincident.example.camel.apache.org/ReportIncident"
style="document" /> <wsdl:input>
<soap:body parts="parameters" use="literal" /> </wsdl:input> <wsdl:output>
<soap:body parts="parameters" use="literal" /> </wsdl:output> </wsdl:operation> </wsdl:binding>
<!-- Service definition --> <wsdl:service name="ReportIncidentService"> <wsdl:port name="ReportIncidentPort" binding="tns:ReportIncidentBinding"> <soap:address location="http://reportincident.example.camel.apache.org" /> </wsdl:port> </wsdl:service>
</wsdl:definitions>
here is my ibm-web-bnd.xml:
<?xml version="1.0" encoding="UTF-8"?> <web-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://websphere.ibm.com/xml/ns/javaee"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd" version="1.0"> <virtual-host name="default_host"/> </web-bnd>
here is my cxf-config.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<!-- implementation of the webservice -->
<bean id="reportIncidentEndpoint"
class="org.apache.camel.example.reportincident.impl.ReportIncidentEndpointImpl" />
<!-- export the webservice using jaxws -->
<jaxws:endpoint id="reportIncident" implementor="#reportIncidentEndpoint"
address="/incident" wsdlLocation="/WEB-INF/wsdl/report_incident.wsdl"
endpointName="s:ReportIncidentPort" serviceName="s:ReportIncidentService"
xmlns:s="http://reportincident.example.camel.apache.org" />
</beans>
here is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Archetype Created Web Application</display-name>
<!-- the listener that kick-starts Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- CXF servlet -->
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- all our webservices are mapped under this URI pattern -->
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/webservices/*</url-pattern>
</servlet-mapping>
<!-- location of spring xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:cxf-config.xml</param-value>
</context-param>
</web-app>
====================
Update
strangely, the last update for SystemOut.log and SystemErr.log were two days ago. i found some logs in C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\ffdc
logs:
FFDC Exception:org.springframework.beans.factory.BeanCreationException SourceId:com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated ProbeId:1341 Reporter:com.ibm.ws.webcontainer.webapp.WebAppImpl#bdd2e142
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cxf' defined in class path resource [META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.bus.spring.SpringBus]: Constructor threw exception; nested exception is org.apache.cxf.bus.extension.ExtensionException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1039)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:985)
.....
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.bus.spring.SpringBus]: Constructor threw exception; nested exception is org.apache.cxf.bus.extension.ExtensionException
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1032)
Caused by: java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/apache/camel/component/cxf/transport/CamelTransportFactory, offset=6
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:273)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:74)
com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I: FFDC Incident emitted on C:\Program Files (x86)\IBM\WebSphere\AppServer\profiles\AppSrv01\logs\ffdc\server1_24638c34_17.05.05_01.11.23.0597458986526819616127.txt com.ibm.ws.webcontainer.servlet.ServletInstance.init 181
com.ibm.ws.webcontainer.VirtualHostImpl addWebApplication SRVE0250I: Web Module Archetype Created Web Application has been bound to default_host[*:9080,*:80,*:9443,*:5060,*:5061,*:443].
WSVR0221I: Application started: camel-example-reportincident_war
WSVR0191I: Composition unit WebSphere:cuname=camel-example-reportincident_war in BLA WebSphere:blaname=camel-example-reportincident_war started.
An UnsupportedClassVersionError means that the class (in this case, CamelTransportFactory) was compiled against a higher level of Java than the JVM that you're running on. If you have a version of WebSphere that supports higher Java spec levels, you'll need to pick up a higher-level JDK; if not, then you'll need a version of the Camel package that supports Java 6.
I have been searching for a while now, and came to the conclusion it may not be possible to change the validation per value of an attribute.
For example I have two "action" nodes, both with a "type" attribute and two elements ("name" and "description")
Only when the value of the "type" attribute is "1" it has an "a" element with "abc" child elements and when the "type" attibute is "2" it has a "bla" element with "yet" child elements.
Example of type 1
<action type="1">
<name>yup</name>
<description>yyy</description>
<a>
<abc>false</abc>
</a>
</action>
Example of type 2
<action type="2">
<name>yup2</name>
<description>RRR</description>
<bla>
<yet />
</bla>
</action>
I want to create one XSD* who whould check both types, is this possible?
And if so, how?
It has to be one XSD because I want to put the XSD on a XML column of a table of a MSSQL database.
You are right, it is not possible with XSD 1.0 which is the only XSD version supported by MSSQL. The best you can get is to create a choice between a and bla, maybe place some constraints on attribute type values, etc. Below is an illustration.
<?xml version="1.0" encoding="utf-8"?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module (http://www.paschidev.com)-->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="action">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:element name="description" type="xs:string" />
<xs:choice>
<xs:element name="a">
<xs:complexType>
<xs:sequence>
<xs:element name="abc" type="xs:boolean" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="bla">
<xs:complexType>
<xs:sequence>
<xs:element name="yet" type="xs:anyType" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:sequence>
<xs:attribute name="type" type="xs:unsignedByte" use="required" />
</xs:complexType>
</xs:element>
</xs:schema>
If you control the XML structure, and still want to use some attribute to control the content model, then xsi:type is the only way to do it in XSD 1.0.
You can use the tool XML Stylus Studio to create any type of complex XSDs.
Check the details: http://www.stylusstudio.com/
I am trying to generate Apex classes from a wsdl file.but i am facing a problem...
Apex Generation Failed
Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}string
Can you please help on that.
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://eapisws.cbp.dhs.gov/ws/manifest1_0/" xmlns:mns="http://eapisws.cbp.dhs.gov/ws/manifest1_0/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<wsdl:types>
<xs:schema targetNamespace="http://eapisws.cbp.dhs.gov/ws/manifest1_0/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mns="http://eapisws.cbp.dhs.gov/ws/manifest1_0/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1_0">
<xs:annotation>
<xs:documentation xml:lang="en">
This is the first release of WSDL file for the APIS FlightManifest Batch Web Service and it is subject to change.
</xs:documentation>
</xs:annotation>
<xs:element name="flightManifest" nillable="false">
<xs:annotation>
<xs:documentation xml:lang="en">Valid UN-EDIFACT document</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="2097152"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="certificationFlightManifest" nillable="false">
<xs:annotation>
<xs:documentation xml:lang="en">Valid UN-EDIFACT document to be certified/validated</xs:documentation>
</xs:annotation>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="2097152"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="submissionResponse" nillable="true" type="xs:string"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="flightManifestRequest">
<wsdl:part element="mns:flightManifest" name="flightManifest"/>
</wsdl:message>
<wsdl:message name="certificationFlightManifestRequest">
<wsdl:part element="mns:certificationFlightManifest" name="certificationFlightManifest"/>
</wsdl:message>
<wsdl:message name="flightManifestResponse">
<wsdl:part element="mns:submissionResponse" name="submissionResponse"/>
</wsdl:message>
<wsdl:portType name="EapisManifest">
<wsdl:operation name="submitFlightManifest">
<wsdl:input message="mns:flightManifestRequest" name="flightManifestRequest"/>
<wsdl:output message="mns:flightManifestResponse" name="flightManifestResponse"/>
</wsdl:operation>
<wsdl:operation name="submitCarrierCertificationRequest">
<wsdl:input message="mns:certificationFlightManifestRequest" name="certificationFlightManifestRequest"/>
<wsdl:output message="mns:flightManifestResponse" name="flightManifestResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="EapisManifestSoapBinding" type="mns:EapisManifest">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="submitFlightManifest">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="flightManifestRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="flightManifestResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="submitCarrierCertificationRequest">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="certificationFlightManifestRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="flightManifestResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EapisManifestService">
<wsdl:port binding="mns:EapisManifestSoapBinding" name="EapisManifest">
<wsdlsoap:address location="https://eapisws.cbp.dhs.gov/apis/eapisws1_0/services/EapisManifest"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The answer to the problem is mentioned in the comment made regarding changing the submission response element from a simple type to a complex type as mentioned in the link.
I hope someone can help me. I'm very new at this. I was wondering if it's possible to get an XSD Schema to dump XML data into multiple SQL tables (using the sql:relation attribute, etc.).
One table is proving no problems, so I just wondered if it's possible to dump data in two. It'd be nice to be able to do this with one XSD Schema, but do I have to make two passes on the XML for the second table?
Thanks for any assistance.
Here's the schema itself:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<!-- Skimlinks/Everyfeed schema -->
<!-- definition of simple elements -->
<xs:element name="title" type="xs:string" sql:field="ProductName"/>
<xs:element name="url" type="xs:string" sql:field="ProductURL"/>
<xs:element name="image_url" type="xs:string" sql:field="ImageURL"/>
<xs:element name="currency" type="xs:string" sql:field="currency"/>
<xs:element name="price" type="xs:string" sql:field="Price"/>
<xs:element name="merchant" type="xs:string" sql:field="Brand" default=" " />
<xs:element name="description" type="xs:string" sql:field="Description" default=" "/>
<xs:element name="item" type="xs:string" sql:field="Category" />
<!-- definition of attributes -->
<xs:attribute name="id" type="xs:string" sql:field="SKU" />
<!-- definition of complex elements -->
<xs:element name="category" sql:relation="ProductDataCategory">
<xs:complexType>
<xs:sequence>
<xs:element ref="item" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="product" sql:relation="ProductData">
<xs:complexType>
<xs:sequence>
<xs:element ref="title"/>
<xs:element ref="url"/>
<xs:element ref="image_url"/>
<xs:element ref="currency"/>
<xs:element ref="price"/>
<xs:element ref="merchant"/>
<xs:element ref="description"/>
<xs:element ref="category"/>
</xs:sequence>
<xs:attribute ref="id" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="products" sql:is-constant="1">
<xs:complexType>
<xs:sequence>
<xs:element ref="product" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="everyFeed" sql:is-constant="1">
<xs:complexType>
<xs:sequence>
<xs:element ref="products" maxOccurs="1" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Here's an example of the XML we're importing:
<?xml version='1.0' encoding='utf-8'?>
<feed version="2">
<numFound>7985</numFound>
<products>
<product id="18639|216623247">
<title>Trouser</title>
<url>http://www.products.com/trousers/trouser/</url>
<image_url>http://www.images.co.uk/images/big/4d624426.jpg</image_url>
<verified_image>True</verified_image>
<currency>GBP</currency>
<price>1000</price>
<prev_price>1000</prev_price>
<firstseen>2010-10-27T00:00:00Z</firstseen>
<lastseen>2010-10-27T00:00:00Z</lastseen>
<merchant id="20748">Yours Clothing</merchant>
<by>Yours Clothing</by>
<description></description>
<category>
<item id="9">Lounge & nightwear</item>
<item id="3">Women</item>
<item id="2">Clothing</item>
<item id="1">Clothing, shoes & accessories</item>
</category>
</product>
</products>
</feed>
As you can see, it attempts to dump into two tables: ProductData and ProductDataCategory. Only the stuff stored in the <item> elements should go in the latter table (in the field category).
The error message reads:
Error: Relationship expected on 'category'
I don't know why :(
Thanks for any assistance in getting this working!
You may need to define a SQL relationship in the XSD file if you are trying to do a bulk import. I ran into a similar problem (this is just an example, not specific to your XSD):
<xs:annotation>
<xs:appinfo>
<sql:relationship name="Detail"
parent="Product"
parent-key="ProductID"
child="Details"
child-key="ProductID"
/>
<sql:relationship name="ProductFiles"
parent="Product"
parent-key="ProductID"
child="Files"
child-key="ProductID"
/>
<sql:relationship name="ProductToList"
parent="Product"
parent-key="ProductID"
child="ProductList"
child-key="ProductID"
/>
<sql:relationship name="ListToProduct"
parent="ProductList"
parent-key="ID"
child="ProductListProduct"
child-key="ProductListID"
/>
</xs:appinfo>
</xs:annotation>
Django,
Why not try something like DBVis - http://www.dbvis.com/ - to create a visual representation of all the relationships in your database and work towards having the xsd match the generated diagram. This'll ensure you get all of these relationships.
See here for an example screeshot for a very simple database - http://www.dbvis.com/products/dbvis/doc/main/doc/ug/databaseExplorer/images/genericschemaview.png
I can vouch for it working well for much larger databases too.
Hopefully this'll help.