Usage of Jibx2WSDL to generate wsdl from java - web-services

I'm using jibx2wsdl plugin to convert wsdl from java.
But for java collection list, i am getting same name for all the lists.
Everytime i generate jibx i manually rename the lists.
Is there a solution for it.
Also let me know if this prob is not there with some other libraries(cxf,xmlbeans,watever..).
Here is one sample i attached of my wsdl for java list.
<collection field="reportingYearList" usage="optional" create-type="java.util.ArrayList">
<value name="**string**" type="java.lang.String">
<collection>

Related

Generate Schematron "see" attribute value

I would like to dynamically generate the Schematron see attribute based on the the user home's directory. I could not get this working. Do you have an idea if this is possible? It needs to work in Oxygen XML. I am not sure if this is technically not possible in Schematron, or if this is a bug in Oxygen XML.
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process">
<sch:pattern>
<sch:rule context="/">
<sch:let name="x" value="if (contains(base-uri(), 'myname'))
then 'http://www.a.com'
else 'http://www.b.com'"/>
<sch:report test="'a' = 'a'">
Hello world: "<sch:value-of select="$x"/>"
</sch:report>
</sch:rule>
</sch:pattern>
</sch:schema>
My goal is to generate a user-specific link to a locally deployed style guide, but, as you can see in the screenshot, the variable x is not resolved.
Maybe you can try to read the “user.home” system property: https://www.saxonica.com/html/documentation12/functions/fn/system-property.html
Using Schxslt it seems the syntax of an XSLT attribute value template in the form of e.g. see="{$x}" in Schematron then generates an SVRL report having the URI in the form of e.g.
<svrl:successful-report location="/" see="http://www.b.com" test="'a' = 'a'">
<svrl:text>
Hello world
</svrl:text>
</svrl:successful-report>
I don't know whether oXygen has any integration for Schxslt as a Schematron validator and for rendering the validation result in the form of SVRL.
To build on the answer by #radu-coravu, you might be able to get the 'user.home' value by using a function in an external XSLT file:
Use xsl:include in your Schematron file to include the XSLT. See, e.g., https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L23
Write a function in the external XSLT that returns the "user.home" system property value
In your rule in your Schematron, use let to get the return value of the function as a variable value. See, e.g., https://github.com/AntennaHouse/focheck/blob/43bd5d491d8b985395c94c3c53083770d8c461b6/schematron/fo-property.sch#L31
Use the Schematron variable in your assert and report just like any other variable

Use UpdateListItems webbservice on Sharepoint using Infopath form without managed code

I need to create a Infopath form that users can use to create posts and update a Sharepoint list.
I have located the list GUID and the Lists.asmx webbservice. I have made sure that I am admin with full rights on the List in question. The list is a basic 2 column (1 line of text).
I have created the CAML template:
<?xml version="1.0" encoding="UTF-8"?>
<Batch OnError="Continue">
<Method ID="1" Cmd="New">
<Field Name="Field1"></Field>
<Field Name="Field2"></Field>
</Method>
</Batch>
Two data connections using the CAML:
XML-file - loading the CAML.
Send data using Lists.asmx-service - "UpdateListItems"-method.
The parameters for the UpdateListItems : tns:listName connected to a variable containing the GUID. tns:updates connected to /Batch in loaded CAML, XML-subtree included.
I have added a Repeating Table using the XMLfile-connection (CAML) where I can fill the column values for the new Listitem.
I have added a button that triggers action rules that use the dataconnection and "UpdateListItems"-method. The button also is tested trigger other rule actions, so the button itself works.
As I try post a new item to the sharepoint-list I receive no error message, everything seems to work fine, but no items is created.
If I change anything, like the GUID or other things, I recieve different error messages, so it appears as Infopath thinks everything works fine, but Sharepoint isn't doing anything with my list. No items is created.
Anyone has any idea of what could it be that goes wrong?
Edit: I have used other webservices from the same Sharepoint-server without any problems.
This suggestion may be a bit dated, but...
I just had a similar problem. By using ULSViewer on the SharePoint server and reading the MSDN documentation I figured out that the Name attribute in the CAML Field tag should be the internal name Sharepoint assigns to your list column when you create it. In my case I had to change the CAML from:
<Field Name="pub1">
to
<Field Name="_x0066_ub1">
I had the same problem - you have to point the Web service submit to site /_vti_bin/lists.asmx not to server /_vti_bin/lists.asmx. For example your site is on address server/site, you should use server/site/_vti_bin/lists.asmx, not server/_vti_bin/lists.asmx. My problem was with some subsites, so you could check it if it's the same to you.
When creating new items using UpdateListItem, you need to include a Field tag for the list's ID column. It should be formatted as such:
<Field Name='ID'>New</Field>
Is Title still a required column in your list (it is by default). If so, try adding that to your XML:
<Field Name='Title'></Field>
and I dont think that
<Field Name='ID'></Field>
is required when doing a NEW command (inserting a new list item), but it is required for an UPDATE command (updating an existing list item) - I certainly didnt need it when I tested this.

How to specify both jaxws and jaxb bindings to achieve #XmlRootElement

I've inherited a project that communicates with a SOAP-based web service. I'm a total noob at this, although have been doing Java for many years and have done a good bit with XML.
We have a WSDL file for the service, which contains the schema at the top and all the message definition stuff below. At the core of the problem, when I try to connect to the service through our code, I get the dreaded unable to marshal type "https.api_blah_com.services.v4.Product" as an element because it is missing an #XmlRootElement annotation]
My project already has a jaxws binding file:
<jaxws:bindings wsdlLocation="../resources/wsdl/BlahAPI.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>
<jaxws:bindings
node="wsdl:definitions/wsdl:types/xs:schema[#targetNamespace='https:api.blah.com/services/v4']">
<jxb:globalBindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xjc:generateElementProperty>true</xjc:generateElementProperty>
</jxb:globalBindings>`
</jaxws:bindings>
</jaxws:bindings>
Now I've read that in order to get all my Java classes generated with #XmlRootElement, I need to add a jaxb:globalBinding turning on simple mode.
I've tried adding to my local copy of the WSDL this:
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings>
<xjc:simple />
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
But the JAXB compiler complains that it cannot honor this globalBindings customization because it's attached to a wrong place or is inconsistent with other bindings.
So I tried adding another bindings file, just for jaxb, like so:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings schemaLocation="../resources/wsdl/blah.wsdl">
<jaxb:globalBindings>
<xjc:simple />
</jaxb:globalBindings>
</jaxb:bindings>
</jaxb:bindings>
But then I get an error that blah.wsdl is not part of this compilation.
I am so close to calling this service...I just cannot get past this one thing, and it's all new to me so I'm not sure what else to try.
I could split out their WSDL into an XSD and a WSDL? Is that required to make this work?
I think you have to bind the xsd file not wsdl at this location. <jaxb:bindings schemaLocation="../resources/wsdl/blah.wsdl">. Please refer to section "External Binding Customization Files" at link.
Not sure if JAXB Binding is configured correctly. The #XmlRootElement required if class forms the root of your element structure. However in SOAP, SOAP element would form root of the XML, Hence check if your ObjectFacory.java class is generated, if generated verify if a method is created for the class type which returns an instance of the class type for example you have class Foo an method `public Foo createFoo() which returns instance of Foo should be present in your ObjectFoacory.java
However I would suggest you to use CXF provided WSDL2java this with client option enabled. It takes few minutes to configure a client code

How do I reproduce Relax NG rules in C++ objects?

At the momemet I am working on part of my application where I need to parse Relax NG schema and reproduce rules within file in C++ objects. I start with example code so I can explain better.
<!-- property.element -->
<define name="property.element">
<element name="property">
<attribute name="type" />
<interleave>
<zeroOrMore>
<ref name="resource.class" />
</zeroOrMore>
<ref name="literal.class" />
</interleave>
</element>
</define>
I want to create object where I can store information like:
[define] name,
element name,
attribute names,
allowed child elements with associated rules (zero or more, one or more).
Then I want to display all possible elements in my GUI where I can add only valid (in terms of Relax NG schema) elements to tree-like structure. For example - I can add only resource.class or literal.class to my property.element, every other possible element is greyed in my GUI when I have selected property.element node in GUI. I use Qt, so I load schema into QDomDocument to get access to DOM tree.
Such mechanism has to be universal i.e. no matter how elements are named, or how its structure is. In my draft I created simple class where I placed several members like: defined_name, element_name, required_attributes, optional_attributes. Currently I am stuck because I do not have any idea how to represent rules in C++ class. If I had constant set of objects on which I work I would hard-code every object, but my objects set is very likely to change drastically over time. Does anyone have any idea?
Convert the RNG file to XSD using TRANG, then convert the XSD to c++ using CodeSynthesis either XSD or XSDe). There are a bunch of samples with XSDe, so there might be one demonstrating how to validate the xml input with the schema rules.
http://www.thaiopensource.com/relaxng/trang.html
http://www.codesynthesis.com/products/xsde/

web service pattern that supports lazy loading of all properties

I am trying to design an endpoint template for a web service. My main requirement is that the caller is able to specify which properties should be populated in the returned result set.
My service returns large lists (up to 1M records) of partial objects as well as individual full objects such as (rough example XML, sorry it's a little verbose)
List:
<items>
<item>
<a>aaa</a>
<b>bbb</b>
</item>
<item>
<a>aaaA</a>
<b>bbbB</b>
</item>
</items>
Detail:
<item>
<a>aaa</a>
<b>bbb</b>
<c>ccc</c>
...
<w>
<x>xxx</x>
<y>yyy</y>
</w>
<z>zzz</z>
</item>
I have considered the following ideas:
Returning the full detail items in the list
Creating a 'list' item type that is shorter
passing a string array of property names that the caller wants to be returned
I am leaning towards the 3rd option but I want something different to that it doesn't support sub objects, I have considered passing the xml schema that you want returned instead of an array.
I would like the API to support lazy loading which is why the 3rd way seems viable as well.
Here's an example of what a function for 3. would look like:
public User GetUser(long ID, string[] properties)
And then the caller could just go:
User.Email = GetUser(User.ID, "Email").Email
Through extensive use of default values and hiding nulls, the returned XML for that would be:
<User>
<ID>123</ID>
<Email>example#example.com</Email>
</User>
Now the problem as mentioned above is trying to make it play nice with things like <w> far above, which itself has sub items as well as the possibility for lists to have sub items.
As I have far too many properties, I cannot have just a ws method for each property.
I am considering option 3. but using an xml schema instead of a string[].. But I can't think of an easy way to define this, I would also like to not have to use String names for properties such as "Email".
The final plan is to have a series of pre-defined schemas that are used commonly and only in advanced cases would we need to actually define the requested properties. But I have no idea of all the systems that will be talking to my API, let alone what properties they might each want (it's not going to be feasible for us to tailor the API for every caller).
Or am I over complicating everything too much?
I found the documentation for the Google APIs on Partial Responses and Partial Updates:
http://googlecode.blogspot.com/2011/07/lightning-fast-performance-tips-for.html
This seems to answer my question.