Issue in WSDL2Java - web-services

I am trying to use wsdl2java utility to generate POJOs. It's working fine for complete WSDL file. However, if a WSDL has
<wsdl:import>
it fails. What's the way to generate POJOs from such WSDLs?
Sample WSDL is:
<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:bns0="urn:OFTCoreLookupDataWsd/OFTCoreLookupDataConfig/document" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="OFTCoreLookupDataWsd" targetNamespace="urn:OFTCoreLookupDataWsd">
<wsdl:import location="https://TARGET:443/OFTCoreLookupData/OFTCoreLookupDataConfig/bindings?wsdl&style=document" namespace="urn:OFTCoreLookupDataWsd/OFTCoreLookupDataConfig/document"/>
<wsdl:service name="OFTCoreLookupData">
<wsdl:port name="OFTCoreLookupDataConfigPort_Document" binding="bns0:OFTCoreLookupDataConfigBinding">
<soap:address location="https://TARGET:443/OFTCoreLookupData/OFTCoreLookupDataConfig?style=document"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The error I am getting is:
The reference to entity "style" must end with the ';' delimiter.
This is on
<wsdl:import>
location in WSDL. Please help.

This is just a guess but you may need to replace the & character in the location attributes URL value with & to have a proper WSDL document. The problem is probably due to XML parsing and not the WSDL itself. Here is how it would look:
<wsdl:import location="https://TARGET:443/OFTCoreLookupData/OFTCoreLookupDataConfig/bindings?wsdl&style=document" namespace="urn:OFTCoreLookupDataWsd/OFTCoreLookupDataConfig/document"/>

Related

wso2ei-6.4.0 and XSLT 3.0 support

I am planning to used XSL version 3.0 for my WSO2 EI application. Because, I need to map JSON to JSON and JSON to XML in my application. Currently I have try with version 2.0. Please refer following code for current implementation.
I need to know how change this version and which jar required in WSO2EI for xsl version 3.0.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" />
<xsl:param name="STATIC_BODY_PARAM"></xsl:param>
<xsl:template match="/availabilityRequest">
<availabilityRequest>
<control>
<userName>
<xsl:value-of select="control/userName" />
</userName>
<passWord>
<xsl:value-of select="control/passWord" />
</passWord>
</control>
....................
</availabilityRequest>
</xsl:template>
</xsl:stylesheet>
When I used version as 3.0, I got following error message. I have added your further reference.
ERROR - XSLTMediator Error creating XSLT transformer using : Value {name ='null', expression =fn:concat('gov:repository/transformation/',$ctx:uri.var.travel_type,'_',$ctx:uri.var.activity,'_',$ctx:uri.var.supplier_id,'_in.xslt')}
net.sf.saxon.trans.LicenseException: Requested feature (XSLT 3.0) requires Saxon-PE
at net.sf.saxon.Configuration.checkLicensedFeature(Configuration.java:584)
at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:331)
at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:207)
at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:132)
at org.apache.synapse.mediators.transform.XSLTMediator.createTemplate(XSLTMediator.java:467)
I don't know anything specifically about WSO2EI, but it appears (from your link) that it is currently running with some older version of Saxon-HE.
Simply substituting the Saxon 9.9 JAR file for the one that is distributed with the product may work, or it may not. It's very likely to work, but it's possible that the stylesheets, or the calling application, depend on something in Saxon that has changed.
If you've tried something, there's no point telling us it doesn't work. You need to tell us exactly how it failed.
You should try running a stylesheet that outputs the value of system-property('xsl:product-version') so you have positive confirmation of which Saxon version is being picked up.
You don't need to make any changes to your stylesheets to use XSLT 3.0 features, but it's a good idea to change the version attribute to version="3.0" for documentation reasons.
I have fixed above problem using following information.
I got the 30 trail license key with registering http://www.saxonica.com/download/download.xml (saxon-license.lic) and it put into /wso2ei-6.4.0/ folder
Remove this jar (saxon.he_9.4.0.wso2v1.jar) on following location. (/wso2ei-6.4.0/wso2/components/plugins)
Also put this jar (saxon9ee.jar) http://www.saxonica.com/download/SaxonEE9-4-0-6J.zip into /wso2ei-6.4.0/lib location
Restart the wso2ei-6.4.0 server
Now xsl:stylesheet version="3.0" working without any issue.
I have got those details from following link. Many thanks for that.
http://nandikajayawardana.blogspot.com/2012/12/how-to-replace-saxonhe940wso2v1jar-in.html

WSDL Definition: what is "urn:arnleadservicewsdl"

I try to create my first webservice on symfony. For that, I have applied this guide, and my Hello World is working: https://symfony.com/doc/current/controller/soap_web_service.html
Now, I try to adapt given WSDL to my own code, but I'm not sure of what to do with this line in the WSDL definition:
xmlns:tns="urn:arnleadservicewsdl"
I guess it's important because it's used in my SoapAction:
<soap:operation soapAction="urn:arnleadservicewsdl#hello" style="rpc"/>
What means this arnleadservicewsdl? Should I change it?
Thanks!

How to add SOAP header parameters to WSDL in sequence without using a complexType definition?

Is it possible to specify SOAP header parameters in the WSDL to be in sequence without using a complexType type definition? Basically, I'm after the following as a request message and I'm trying to specify in the WSDL that two tags, HeaderParam1 and HeaderParam2, should be present in the header in sequence.
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Header xmlns:m="http://test.com">
<m:HeaderParam1>ABC</m:HeaderParam1>
<m:HeaderParam2>DEF</m:HeaderParam2>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<m:search_Input xmlns:m="http://test.com/CustomUI">
<m:DetailParam1>String</m:DetailParam1>
<m:DetailParam2>String</m:DetailParam2>
</m:search_Input>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I can't figure out how to make that specification in the WSDL that those two header parameters should be in sequence without defining them as part of a complexType definition under the SOAP header eg.
<SOAP-ENV:Header xmlns:m="http://test.com">
<m:SubHeader>
<m:HeaderParam1>ABC</m:HeaderParam1>
<m:HeaderParam2>DEF</m:HeaderParam2>
</m:SubHeader>
</SOAP-ENV:Header>

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

Usage of Jibx2WSDL to generate wsdl from java

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>