XSD, JaxWS, and Glassfish - web-services

I have a xsd with quite a few pattern restrictions in it and this xsd is used in our wsdl. When we deploy the ear to glassfish and bring up the wsdl and xsd in a browser all of our pattern restrictions are stripped out. Why? How can I eliminate the stripping of our restrictions.
Here is a snippet:
<xsd:complexType name="len">
<xsd:sequence>
<xsd:element name="value" type="tns:dms_len"/>
<xsd:element name="new_value" type="tns:dms_len" minOccurs="0"></xsd:element>
</xsd:sequence>
<xsd:attribute name="action" type="tns:update_actions"></xsd:attribute>
</xsd:complexType>
Here is what it looks like after it is deployed:
<!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.3.1-hudson-749-SNAPSHOT. -->
...
<xs:complexType name="len">
<xs:sequence>
<xs:element name="value" type="xs:string"></xs:element>
<xs:element name="new_value" type="xs:string" minOccurs="0"></xs:element>
</xs:sequence>
<xs:attribute name="action" type="tns:update_actions"></xs:attribute>
</xs:complexType>
Notice how value and new_value are now just plain strings.
Update:
It seems this only happens when I deploy using netbeans, when I deploy from the glassfish console it the pattern restrictions are still there. Why netbeans?

Looks like glassfish does not recognize your xsd when deployed from NetBeans and generates its own.
So first of all, verify that the deployed version uses the correct xsd. Deploying from NetBeans utilizes directory deployment e.g. it does not deploy the ear file but the content in your project directory.

Related

Adding annotation and documentation child elements to Coldfusion generated WSDL

I am working on a ColdFusion SOAP web service and I cannot figure out how to add an annotation child element and documentation child element to the WSDL that is generated.
This is my intended output:
<xsd:element name="country" minOccurs="1" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>The ISO 3166-1 alpha-2 country code
</xsd:documentation>
</xsd:annotation>
....
</xsd:element>
My ColdFusion generated WSDL looks like this:
<xs:element minOccurs="0" name="country" nillable="true" type="xs:string"/>
I have defined the arguments in the cfcomponent > cffunction like this:
<cfargument name="country" type="string" required="true" default="" hint="The ISO 3166-1 alpha-2 country code"/>
Using the hint attribute does not add the annotation and documentation child elements but I cannot find another way to achieve this in the ColdFusion docs.
In searching for an answer I have seen ColdFusion SOAP web services described as "half-baked". Am I setting myself up for failure by trying this at all?
If you want to control the WSDL that is generated by ColdFusion you can use the wsdlfile attribute of the cfcomponent tag to use a pre-defined WSDL file instead of using the WSDL file generated by ColdFusion.
From the Producing WSDL files page:
For complete control of the WSDL, advanced users can specify the cfcomponent wsdlFile attribute to use a predefined WSDL file.
And from the cfcomponent documentation page:
wsdlfile - Optional - A properly formatted WSDL file to be used instead of WSDL generated by ColdFusion.
Most likely you will need to play around with this a bit to get the output how you want it. I posted this answer to another similar question a while back - https://stackoverflow.com/a/17174756/1636917 Notice the comment that was posted there regarding the endpoint URL needing to be within the WSDL.

How can I mark a SOAP Header as optional in WSDL?

I have a wsdl with an optional header:
<s:element name="AuthIdentifier" type="tns:AuthIdentifier"/>
<s:complexType name="AuthIdentifier">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="identifier" type="s:string"/>
</s:sequence>
<s:anyAttribute/>
</s:complexType>
The client is using an integration software (tibco) to connect to my service and claims that the header is required, so he must send it with an empty value:
<Header.AuthIdentifier>
<ns0:AuthIdentifier xmlns:ns0 = "http://www.tal.com/schemas"/>
</Header.AuthIdentifier>
How do I make it optional? So that he won't have to send the whole header at all? Is there a minOccurs or something like that? Or is it already optional as it is now?
According to "Web Service Contract Design & Versioning" Thomas Erl et al (ISBN-13: 978-0-13-613517-3) Chapter 15.4, Defining SOAP Blocks in WSDL:
The WSDL 1.1 Specification is unclear about whether SOAP headers
described in a WSDL document must be included by consumers or not. The
WS-I Basic Profile made it mandatory for consumers to include them,
but WDL 2.0 provides the choice as to whether consumers should be
forced to include them or not. Page 472.
In WSDL 2.0 you can set the attribute wsdl:required="false" in the custom SOAP header block to indicate whether consumers must include this header block.

how to change the attributes in a wsdl using jax-ws specific soap webservices

I was reading about web services , and was creating wsdl from jax-ws source code, i was able to create the wsdl perfectly , i have a many inputs in a request where i need to set minOccurs and maxOccurs for a specific string input in a request, how can i do this via java code. help me in this
my wsdl piece code
<xs:element name="person"><xs:complexType><xs:sequence>
<xs:element name="employee" type="xs:string" minOccurs="1" maxOccurs="10"/>
<xs:element name="member" type="xs:string"/> </xs:sequence></xs:complexType></xs:element>
You cannot define such limit by jaxb anotations on your classes.
You can have 1, or unbound only as maxoccurency

How to add external network using vSphere API

I want to add external network using vSphere API but didn't got any idea.
Please give me links.
Kindly check vSphere API documentation for details and procedures
There is an API service method:: AddVirtualNIC
<element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:vim25="urn:vim25" name="AddVirtualNic" type="vim25:AddVirtualNicRequestType"/>
<element xmlns="http://www.w3.org/2001/XMLSchema" xmlns:vim25="urn:vim25" name="AddVirtualNicResponse">
<complexType>
<sequence>
<element name="returnval" type="xsd:string"/>
</sequence>
</complexType>
</element>
Proceed further with configuration details on vSphere HostNetworkSystem <ManagedOBJECT>

How to quickly create a web-service for testing purposes?

I have to make a client for a web-service. The web-service is not ready yet. I want to make a web-service server with one mockup method. This method must take one parameter - a collection of objects. The only thing that I have for now is the xsd describing the data type for the web-service's method parameter. Here it is
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://localhost/1csite/Contractors" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://localhost/1csite/Contractors">
<xsd:complexType name="Contractor">
<xsd:sequence>
<xsd:element name="Code" type="xsd:string"/>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="ParentCode" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="Contractors">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Element" nillable="true" type="tns:Contractor"/>
</xsd:sequence>
</xsd:complexType>
How can I quickly make a web-service server with one method taking objects of this data type?
Thank you.
If I understand you correctly, you need a temporary server for a not yet complete web service, so you can build a client against the service. If that is the case, and you are comfortable with Linux, you can set up your own Apache web server and use the Apache Axis2 web services engine, along with your xsd file. Check out the quick start guide.