Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Serializing Documenation elements
Serializing Documenation elements [message #231351] Fri, 15 May 2009 07:27 Go to next message
Ravikanth Somayaji is currently offline Ravikanth Somayaji
Messages: 39
Registered: July 2009
Location: Oxford
Member
Hi,

I'm using the Wsdl EMF API, to create WSDLs programmatically.

The problem I'm facing currently is
when i add a documentation element to a WSDL element, it isn't serializing
it. However, when i debug through the code, I do find that the value are
transiently retrieved.

Is there some flag/switch i need to turn on, in order to serialize these
elements??

-Ravi
Re: Serializing Documenation elements [message #231410 is a reply to message #231351] Fri, 15 May 2009 13:51 Go to previous messageGo to next message
Gabriel Indik is currently offline Gabriel Indik
Messages: 16
Registered: July 2009
Junior Member
Ravi,
To better understand the problem, could you please paste a small code
fragment/snippet that shows the API calls you are making to incorporate
the documentation elements as well as the document serialization?
Re: Serializing Documenation elements [message #231491 is a reply to message #231410] Mon, 18 May 2009 06:03 Go to previous messageGo to next message
Ravikanth Somayaji is currently offline Ravikanth Somayaji
Messages: 39
Registered: July 2009
Location: Oxford
Member
Thanks for the reply Gabriel.

That's the piece I have in my code to add a documentation element to the
wsdlelement.
public static void createDocElement(Object definitionObj,
Object wsdlElementObj, String elementName, String attrib,
String val) {
if (definitionObj instanceof Definition) {
Definition definition = (Definition) definitionObj;
if (wsdlElementObj instanceof ExtensibleElement) {
WSDLElement wsdlElement = (WSDLElement) wsdlElementObj;
Attr attr =

definition.getDocument().createAttribute("ProcessInfo");
attr.setValue(elementName + ":::" + val);
Element documentationElement =
wsdlElement.getDocumentationElement();
if (documentationElement == null) {
documentationElement =
definition.getDocument()
.createElement("DocumentationElement");

}
documentationElement.setAttributeNode(attr);
wsdlElement.setDocumentationElement(documentationElement);
try {
definition.eResource().save(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Document##"
+ wsdlElement.getDocumentationElement());
}
}

However, the wsdl fragment for which i run the code against still looks
like this
<wsdl:portType name="RTestW">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:NewOperationRequest"/>
<wsdl:output message="tns:NewOperationResponse"/>
</wsdl:operation>
</wsdl:portType>

and I would expect
<wsdl:portType name="RTestW">
<wsdl:documentation>ProcessInfo=elementName:::value</wsdl:documentation >
<wsdl:operation name="NewOperation">

<wsdl:documentation>ProcessInfo=elementName:::value</wsdl:documentation >
<wsdl:input message="tns:NewOperationRequest"/>
<wsdl:output message="tns:NewOperationResponse"/>
</wsdl:operation>
</wsdl:portType>



Gabriel Indik wrote:

> Ravi,
> To better understand the problem, could you please paste a small code
> fragment/snippet that shows the API calls you are making to incorporate
> the documentation elements as well as the document serialization?
Re: Serializing Documenation elements [message #231636 is a reply to message #231491] Tue, 19 May 2009 17:26 Go to previous messageGo to next message
Raymond Lai is currently offline Raymond Lai
Messages: 6
Registered: July 2009
Junior Member
Ravi,

Are you using the WSDL models as standalone models? If so, maybe you need
to manually sync the changes from the DOM to the EMF models.

See if the following line helps or not?

try {
====> definition.elementChanged(definition.getElement());
definition.eResource().save(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Raymond
Re: Serializing Documenation elements [message #231652 is a reply to message #231491] Wed, 20 May 2009 01:28 Go to previous message
Eclipse User
Originally posted by: valentinbaciu.hotmail.com

Ravikanath, you seem to have run into a limitation of the WSDL EMF model.
I have opened https://bugs.eclipse.org/bugs/show_bug.cgi?id=277056 to track
this.
In the mean time, try this working example, which shows you how to work
around the limitation.

public class DocumentationSample extends TestCase
{
private static final String WSDL_PREFIX = "wsdl"; //$NON-NLS-1$

public void testSupportsDocumentationElements() throws Exception
{
ResourceSetImpl resourceSet = new ResourceSetImpl();
WSDLResourceImpl wsdlResource =
(WSDLResourceImpl)resourceSet.createResource(URI.createFileU RI( "documentationTest.wsdl"));

WSDLFactory factory = WSDLFactory.eINSTANCE;
Definition definition = factory.createDefinition();
wsdlResource.getContents().add(definition);
definition.setTargetNamespace("http://www.example.org");
definition.addNamespace(WSDL_PREFIX, WSDLConstants.WSDL_NAMESPACE_URI);

definition.updateElement(true);

Document document = definition.getDocument();

Element documentationElement =
document.createElementNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDL_PREFIX + ":"
+ WSDLConstants.DOCUMENTATION_ELEMENT_TAG);

// Workaround WSDL EMF model limitation.

Element definitionElement = definition.getElement();

// Change this line appropriately to ,ake sure you insert
// the definition element as the first child.
definitionElement.insertBefore(documentationElement, null);

// End workaround

definition.setDocumentationElement(documentationElement);

Element docChild = document.createElement("DocumentationElement");
docChild.setAttribute("ProcessInfo", "someValue");
documentationElement.appendChild(docChild);

wsdlResource.save(null);
}
}

The above code creates a WSDL document that looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.example.org">
<wsdl:documentation>
<DocumentationElement ProcessInfo="someValue"/>
</wsdl:documentation>
</wsdl:definitions>

"Ravikanth " <ravikanth.somayaji@gmail.com> wrote in message
news:c92b98a5d999b68c6119fdf781322c51$1@www.eclipse.org...
> Thanks for the reply Gabriel.
>
> That's the piece I have in my code to add a documentation element to the
> wsdlelement.
> public static void createDocElement(Object definitionObj,
> Object wsdlElementObj, String elementName, String attrib,
> String val) {
> if (definitionObj instanceof Definition) {
> Definition definition = (Definition) definitionObj;
> if (wsdlElementObj instanceof ExtensibleElement) {
> WSDLElement wsdlElement = (WSDLElement) wsdlElementObj;
> Attr attr =
>
> definition.getDocument().createAttribute("ProcessInfo");
> attr.setValue(elementName + ":::" + val);
> Element documentationElement =
> wsdlElement.getDocumentationElement();
> if (documentationElement == null) {
> documentationElement =
> definition.getDocument()
> .createElement("DocumentationElement");
>
> }
> documentationElement.setAttributeNode(attr);
> wsdlElement.setDocumentationElement(documentationElement);
> try {
> definition.eResource().save(null);
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> System.out.println("Document##"
> + wsdlElement.getDocumentationElement());
> }
> }
>
> However, the wsdl fragment for which i run the code against still looks
> like this
> <wsdl:portType name="RTestW">
> <wsdl:operation name="NewOperation">
> <wsdl:input message="tns:NewOperationRequest"/>
> <wsdl:output message="tns:NewOperationResponse"/>
> </wsdl:operation>
> </wsdl:portType>
>
> and I would expect <wsdl:portType name="RTestW">
> <wsdl:documentation>ProcessInfo=elementName:::value</wsdl:documentation >
> <wsdl:operation name="NewOperation">
>
> <wsdl:documentation>ProcessInfo=elementName:::value</wsdl:documentation >
> <wsdl:input message="tns:NewOperationRequest"/>
> <wsdl:output message="tns:NewOperationResponse"/>
> </wsdl:operation>
> </wsdl:portType>
>
>
>
> Gabriel Indik wrote:
>
>> Ravi,
>> To better understand the problem, could you please paste a small code
>> fragment/snippet that shows the API calls you are making to incorporate
>> the documentation elements as well as the document serialization?
>
Previous Topic:Tomcat and Eclipse for my RCP
Next Topic:WTP headless build issues...
Goto Forum:
  


Current Time: Fri Aug 22 04:02:38 EDT 2014

Powered by FUDForum. Page generated in 0.02058 seconds