Adding annotation and documentation child elements to Coldfusion generated WSDL - web-services

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.

Related

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

Change the name of the Request Element in XSD file of a Spring Web Service

I have a Web Service with a method called TestMethod.
On the XSD file I have this:
<element name="TestMethodResponse">
<complexType>
<sequence>
<element name="codRta" type="int" />
</sequence>
</complexType>
</element>
<element name="TestMethodRequest">
<complexType>
<sequence>
</sequence>
</complexType>
</element>
As you can see, there is a TestMethodRequest and TestMethodResponse
This work OK!
Now, I need to make some changes.
This Web Service will be used to replace another Web Service.
So I need to call the methods on my Web Service equal to the older one.
That because my client have a Desktop Application (using the older Web Service) working, and off course, dosen't want to change it.
My problem is with the WSDL of the older Web Service.
If you see the WSDL, the method "TestMethod" doesn't have a TestMethodRequest element. It have a "TestMethod" element (without the Request part).
It is posible to do that? How can I do?
How can I change the XSD to name the Request element "TestMethod" instead of "TestMethodRequest "?(and keep the Web Services working)
Thanks and sorry for my poor english

Issue using .net web service from ColdFusion

I've been running into some challenges with a web service I'm trying to use of from ColdFusion. The service (AccountsService), has a method, GetAccountLinksByUser that returns accounts associated with a given user. This method accepts two arguments:
UPN, which is just a unique string to identify the user. This is no problem, as far as I can tell.
sourceType. This is ultimately a string, but is defined in the WSDL as simple type with one of three possible values. Here's a relevant sections of XML from the WSDL:
<xsd:simpleType name="SourceType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="All"/>
<xsd:enumeration value="Manual"/>
<xsd:enumeration value="System"/>
</xsd:restriction>
</xsd:simpleType>
The problem is that I can't seem to just pass the string "All", "Manual", or "System" into the web service. The stub that CF generates has the following signature for this method:
getAccountLinksByUser(java.lang.String, org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType)
This appears to suggest that I need to pass in an instance of org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType. However, I can't create an instance of that type (easily) as it doesn't appear to be in a class path that CF searches. I tried wrapping the classes that CF generates into the /stubs directory into a jar and putting them in a class path. This did work, in that I could now create an instance of org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType, but I was still unable to pass that into the getAccountLinksByUser method.
As requested, here is the code I'm using to call the web service:
<cfset accountsService = CreateObject("WebService", "http://local.hostname/libraries/com/foo/bar/staging/AccountsService.wsdl") />
<cfset SourceType = CreateObject("java", "org.datacontract.schemas._2004._07.tfonline_services_accounts_datacontracts.SourceType") />
<cfset accounts = accountsService.getAccountLinksByUser("username#domain", SourceType.All) />
More information. The publisher of the web service does not publish their WSDL publicly. This was emailed to me and I'm loading the WSDL from my my local development site.
The specific error I'm getting is:
Cannot perform web service invocation getAccountLinksByUser.
The fault returned when invoking the web service operation is:
Cannot perform web service invocation getAccountLinksByUser. The fault
returned when invoking the web service operation is: ''
java.lang.IllegalArgumentException: argument type mismatch
I'm not really sure where to head at this point. Any suggestions?
The service is written in .NET.
I ran a few tests and it seems related to the switch to Axis2 in CF10. I am honestly not sure exactly what about enumeration's changed between 1 and 2. However, setting the version level back to Axis1 should do the trick:
<cfscript>
args = { refreshWSDL=true, wsversion=1 };
ws = createObject("webservice", "http://mysite/test.asmx?wsdl", args);
result = ws.getAccountLinksByUser("test#somewhere.com", "All");
writeDump(result);
</cfscript>

WebLogic does not validate minOccurs="1" in webservices

My WebService is deployed on WebLogic 10.3.3.
WSDL/XSD describes input parameter number as mandatory:
<xs:element minOccurs="1" maxOccurs="1" name="number" type="xs:int"/>
MinOccurs="1" means that XML message must contain <number> tag, isn't it?
I expect WebLogic has to validate all requests and server error response should be thrown when request is invalid.
Unfortunatelly, my SOAP client is able to send SOAP request without <number> tag and my webservice implementation receives such an invalid request.
Could you tell me please, is it correct behavior or is it defect in WebLogic?
Should my webservice perform it's own XML validation?
WebLogic does not have XSD Schema Validation enabled by default. You can enable it by adding an annotation to your webservice #SchemaValidation (make sure it com.sun.xml.ws.developer version and NOT the com.sun.xml.ws.internal.developer). However this kind of validation does not work too well if you have a complex XSD Schema (e.g. had problems with GS-1 XSD schemas). I think it has something to do with the xercex parser for xml files that weblogic uses since it can't always find all the elements, however so far I was unable to get to the bottom of it. It works fine for simple schemas.
If you need to validate complex schemas it is better to write your own validator and add it to the WS Message Handler. This is quite a bit of work but you then have full control of it and so far I have found no other solution.
Take a look at my answer here for a similiar situation.
As already pointed, you can use the provided #SchemaValidation annotation that tells WebLogic to validate the message for you.

XSD, JaxWS, and Glassfish

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.