Are XSD type definitions validated at compile time? - eclipse

In one of my projects, I used to have a WSDL element defined as having length of 20:
<xs:element name="LastName" type="mns:String20Type" />
Where String20Type is defined in an internal XSD:
<xs:simpleType name="String20Type">
<xs:restriction base="xs:string">
<xs:maxLength value="20" />
</xs:restriction>
</xs:simpleType>
To increase the length of that element, I changed String20Type to String40Type without adding a type definition into the schema and rebuilt:
<xs:element name="LastName" type="mns:String40Type" />
The build completed successfully without any error, warning, complaint or hint of any type.
Why?
How did the system know what String40Type is?

As requested:
Hmm... sounds like either Eclipse is not validating it properly or you have that type defined... somewhere. I use LiquidXML and Altova XML Spy. I suggest you try those specialized IDE packages and have them validate it and see where the error lies. They have free trials so give that a shot.

Related

WSDL not building correctly when extension and elements are used in the same object

Whenever I try to build the wsdl file it won't correctly build the object when its inherited and has a sequence of elements listed. For example...
<xs:complexType name="Triangle">
<xs:annotation>
<xs:documentation>blah blah blah </xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="Shape">
<xs:sequence>
<xs:element ref="angle1"/>
<xs:element ref="angle2"/>
<xs:element ref="angle3"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>`
This builds the java Triangle class with the extension base only and none of the 3 elements listed above. However if i remove the extension, the 3 elements populate after building the wsdl file. Its only when I have both the extension tag and element tag that the element stuff doesn't appear. Anyone have insight as to what is going on?

Element with name "Con" cannot be generated by XJC

Hello guys i have following problem when generating Java classes from XSD file. This is taken from PMML xsd file, where the element named "Con" is located. These two are the only places this element is used. Even with this smallest possible example it doesnt work.
<xs:element name="Neuron">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="Con"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Con">
<xs:complexType>
<xs:attribute name="from" type="xs:double" use="required"/>
</xs:complexType>
</xs:element>
When i try to generate classes with the name "Con" in there i get following error:
unable to write files: C:\myPathHere\build\generated\jaxbCache\PMML-4-3\org\dmg\pmml_4_3\Con.java (The handle is invalid)
Interestingly if i change the name of the element to anything else it is working without problem and all classes are generated correctly. Is there something im missing here? Sadly could not find anything related to name "Con" being excluded from valid element names in XSD for JAXB java class generation.
Thanks for any ideas.
Con is a reserved word for windows. You can't create Con.txt itself on windows. What you can do is customize the binding, give a different file name and use the #XmlElement(name="Con") annotation
See Class Binding Declarations to customize the classname

Pivot Script Producer - Bug Found

I'm sorry to have to submit through this channel.
The report issue feature on your website won't just let me submit my request. Error enclosed:
SoftFluent, SoftFluent, we have a problem! An unidentified error has occured
Problem: Pivot Script producer crashes
Reproductible: Yes
Use case:
Basic use case is having 2 entities named the same (concept is the same but spreaded over different namespace and schema), yet referencing a third entity.
After extending SqlPivotProducer, it appears that referenced table would find its constraints (1 PK and 2 FK) but one of the 2 FK would have a null ReferenceTable leading to nullpointer.
Steps to reproduce:
Have this model below and try to generate Pivot Script File
<cf:project defaultNamespace="Model1" xmlns:cf="http://www.softfluent.com/codefluent/2005/1" xmlns:cfx="http://www.softfluent.com/codefluent/modeler/2008/1" xmlns:cfsps="http://www.softfluent.com/codefluent/producers.sqlpivotscript/2013/1" xmlns:cfps="http://www.softfluent.com/codefluent/producers.sqlserver/2005/1" xmlns:cfspsi="http://www.softfluent.com/codefluent/producers.ixcyssqlpivotscript/2016/1" createDefaultMethodForms="true" createDefaultApplication="false" createDefaultHints="false">
<cf:import path="Default.Surface.cfp" />
<cf:entity name="Entity" schema="SchemaA" namespace="Model1.NamespaceA" persistenceName="Entity">
<cf:property name="EntityId" key="true" />
<cf:property name="EntityC" typeName="{0}.NamespaceC.EntityC" />
</cf:entity>
<cf:entity name="Entity" schema="SchemaB" namespace="Model1.NamespaceB" persistenceName="Entity">
<cf:property name="EntityId" key="true" />
<cf:property name="EntityC" typeName="{0}.NamespaceC.EntityC" />
</cf:entity>
<cf:entity name="EntityC" namespace="Model1.NamespaceC">
<cf:property name="EntityCId" key="true" />
</cf:entity>
<cf:producer name="SQL Server Pivot Script" typeName="CodeFluent.Producers.SqlServer.SqlPivotScriptProducer, CodeFluent.Producers.SqlServer">
<cf:configuration targetDirectory="..\Database1" connectionString="Server=127.0.0.1;Database=EntityA;Integrated Security=true;Application Name=Application;" cfx:targetProject="..\Database1\Database1.sqlproj" cfx:targetProjectLayout="Update" />
</cf:producer>
<cf:producer enabled="false" name="SQL Server" typeName="CodeFluent.Producers.SqlServer.SqlServerProducer, CodeFluent.Producers.SqlServer">
<cf:configuration produceViews="true" targetDirectory="..\Database1" connectionString="Server=127.0.0.1;Database=EntityA;Integrated Security=true;Application Name=FedPeche33_Association;" cfx:targetProject="..\Database1\Database1.sqlproj" cfx:targetProjectLayout="Update, DontRemove" produceSchemas="true" />
</cf:producer>
<cf:producer enabled="false" name="Asp.Net Identity" typeName="CodeFluent.Producers.SqlServer.IxcysSqlPivotScriptProducer, SqlServerPivotIxcys">
<cf:configuration targetDirectory="..\Database1" cfx:targetProject="..\Database1\Database1.sqlproj" cfx:targetProjectLayout="Update" connectionString="Server=127.0.0.1;Database=EntityA;Integrated Security=true;Application Name=FedPeche33_Association;" />
</cf:producer>
</cf:project>
Captured stacktrace:
System.NullReferenceException was unhandled
Message: An unhandled exception of type 'System.NullReferenceException' occurred in CodeFluent.Producers.SqlServer.dll
Additional information: Object reference not set to an instance of an object.
For the time being I would consider renaming my entities to go over this problem.
Thanks for your support
I also had this non-blocking exception on my environment while debugging pivot script generation:
DateTimeInvalidLocalFormat occurred
Message: Managed Debugging Assistant 'DateTimeInvalidLocalFormat' has detected a problem in 'C:\Program Files (x86)\SoftFluent\CodeFluent\Modeler\CodeFluent.Build4.exe'.
Additional information: A UTC DateTime is being converted to text in a format that is only correct for local times. This can happen when calling DateTime.ToString using the 'z' format specifier, which will include a local time zone offset in the output. In that case, either use the 'Z' format specifier, which designates a UTC time, or use the 'o' format string, which is the recommended way to persist a DateTime in text. This can also occur when passing a DateTime to be serialized by XmlConvert or DataSet. If using XmlConvert.ToString, pass in XmlDateTimeSerializationMode.RoundtripKind to serialize correctly. If using DataSet, set the DateTimeMode on the DataColumn object to DataSetDateTime.Utc.

Enum type erased to string in SOAP WSDL after deployed on JBoss

Here is a SOAP web service. It was initially defined via wsdl/xsd. Then Java classes was generated by Apache CXF. Then a war was built and deployed onto JBoss.
The problem. The wsdl JBoss exposes into the world significantly differs from the one written by me - in the example below custom enum type Fruit was erased into raw string type. As result, there is no type check about the enum - any non empty string value could be "successfully" passed by a client to the service without a schema-not-satisfied error; Java service implementation receives null enum in such cases (although it's a mandatory param).
The question. How prevent such enum type erasure in runtime? Or. How to teach the web service to check requests strictly about enums?
The original definition of the service:
<!-- SOAP WSDL: -->
<wsdl:operation name="pickFruit">
<soap:operation soapAction="http://www.example.com/ws/pickFruit"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<!-- XSD, the request: -->
<xs:element name="pickFruitRequest" type="pickFruitRequest"/>
<xs:complexType name="pickFruitRequest">
<xs:sequence>
<xs:element name="fruit" type="Fruit" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<!-- XSD, the enum: -->
<xs:simpleType name="Fruit">
<xs:restriction base="xs:string">
<xs:enumeration value="orange"/>
<xs:enumeration value="kiwi"/>
<xs:enumeration value="potato"/>
</xs:restriction>
</xs:simpleType>
The WSDL exposed by JBoss:
<!-- http://localhost:8080/example/PickFruitEndpoint?wsdl -->
<xs:complexType name="pickFruitRequest">
<xs:sequence>
<xs:element name="fruit" type="xs:string"/>
</xs:sequence>
</xs:complexType>
UPDATE. Request class auto-generated by CXF:
public class PickFruitRequest {
#XmlElement(required = true)
#XmlSchemaType(name = "string") // it forces type erasure!
protected Fruit fruit;
Although <xs:restriction base="xs:string"> looks like a correct definition for an enum, it turns it leads CXF to add a #XmlSchemaType(name = "string") which leads JBoss to generate a "bad" wsdl in runtime.
JBoss EAP 6.4.0, Spring 4, Apache CXF, Java 7

odatagen: Failed to generate proxy classes. Please verify the metadata (iOS)

Im working on Open Data Protocol (OData) which is a standardized protocol for creating and consuming data API's.
OData builds on core protocols like HTTP and commonly accepted methodologies like REST .
I have installed, configured and built OData successfully on iOS6
Currently I'm creating a Proxy class to connect to the OData Service using the following commands:
cd /Users/Shamsu/Applications/ODataObjC/ODataSDKV1-1.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug
./odatagen /uri=http://35.35.6.4/MyApp.MyApp3D.DataService/MyApp3DDataService.svc/ /out=/Users/Ramshad/Applications/ODataObjC/ODataSDKV1-1.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug /u=sa /p=123
However, I'm getting the error: "odatagen: Failed to generate proxy classes. Please verify the metadata"
I can see the "metadata.xml" file is updated as
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="1.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="MyAppDBModel" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="User">
<Key>
<PropertyRef Name="UserID" />
</Key>
<Property Name="UserID" Type="Edm.Guid" Nullable="false" />
<Property Name="UserName" Type="Edm.String" MaxLength="10" FixedLength="true" Unicode="true" />
<Property Name="UserDescription" Type="Edm.String" MaxLength="50" FixedLength="false" Unicode="true" />
<Property Name="Active" Type="Edm.Int64" />
</EntityType>
</Schema>
<Schema Namespace="MyApp.MyApp3D.DataService" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityContainer Name="MyAppDBEntities" m:IsDefaultEntityContainer="true" p6:LazyLoadingEnabled="true" xmlns:p6="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
<EntitySet Name="User" EntityType="MyAppDBModel.User" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx> "
Note: the metadata.xml file is located at out param location (/Users/Ramshad/Applications/ODataObjC/ODataSDKV11.3/Framework/bin/ODatagenBinary/MacOSX10.7.sdk/Debug /metadata.xml)
I'm unable to identify the issue. Any problem with my windows WCF service /ODataService configuration/database configuration ? Permission assigned as * (read,write).
Any help on this issue is appreciated.
Thanks.
I looked a bit closer at the XSLT document I linked to in my original comment, and it seems that the odatagen tool hasn't been updated to work with CSDL v3. The version of CSDL (i.e., the format used to serialize the metadata document) is indicated by the xml namespace of the Schema element. In your metadata, that namespace is http://schemas.microsoft.com/ado/2009/11/edm, which indicates CSDL v3. You can see in the XSLT document here that this namespace isn't recognized by the odatagen tool.
Since the odatagen tool is open source (see the source on github), you can try to tweak the code and XSLT files to make it work for your situation. You could try to just add the v3 namespace to the recognized schema namespaces, and if your metadata doesn't use any v3 features, I would imagine it would just work. Off the top of my head I'm not sure of the exact differences between v2 and v3, so I can't immediately say whether the metadata you've posted above would be valid in CSDL v2.
Alternatively, you could try to generate the $metadata document so that it's using CSDL v2 instead.
Sorry I don't have a better answer for you. Unfortunately, the odatagen tool has fallen a bit behind. But you're more than welcome to contribute to the project :)