Mobile URIs for testing access from REST clients

Posted by agent_008_nl on 05-Dec-2014 07:43

Hi,

OE11.3.0

I'm trying to test a mobile service using the restclient-tool. A normal restservice is working ok, but mobile service not.

Do I need servicepack 2? Anyway, http://localhost:8980/CustomerMobile/ in chrome gives a good response, http://localhost:8980/CustomerMobile/rest/CustomerMobile?_wadl gives (and here method name="PUT" for each resource path seems not ok to me)

<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<grammars/>
<resources base="http://localhost:8980/CustomerMobile/rest/CustomerMobile">
<resource path="/dsCustomer/UpdatedsCustomer">
<method name="PUT">
<response status="204"/>
</method>
</resource>
<resource path="/dsCustomer/CreatedsCustomer">
<method name="PUT">
<response status="204"/>
</method>
</resource>
<resource path="/dsCustomer/DeletedsCustomer">
<method name="PUT">
<response status="204"/>
</method>
</resource>
<resource path="/dsCustomer/ReaddsCustomer">
<method name="PUT">
<response status="204"/>
</method>
</resource>
</resources>
</application>

Anyway, when I GET http://localhost:8980/CustomerMobile/rest/CustomerMobile/dsCustomer/ReaddsCustomer?filter=

response is

HTTP/1.1 405 Method Not Allowed

Server: Apache-Coyote/1.1

Content-Length: 0

Date: Fri, 05 Dec 2014 13:17:48 GMT

Allow: PUT,OPTIONS

And when I PUT the same uri I get

HTTP/1.1 415 Unsupported Media Type

Server: Apache-Coyote/1.1

Content-Length: 0

Date: Fri, 05 Dec 2014 13:18:46 GMT

The wadl generated seems not ok. How do I get it right? I have not seen a way to configure the methods like for a plain restservice (edit mobile service dialog).

--
Kind regards,

Stefan Houtzager

Houtzager ICT consultancy & development

www.linkedin.com/in/stefanhoutzager

 

 

Posted by Anil Kumar on 05-Dec-2014 08:42

Hi,

Sorry some how the reply mail didn't reach completely. Following is the complete reply on the same.

By looking at the generated catalog and the wadl files, seems the Business Entity file has all methods with invoke as the operation as below:

@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/ReadCustomer", alias="", mediaType="application/json"). 
    METHOD PUBLIC VOID ReadCustomer(
                    
    END METHOD.
         
    /*------------------------------------------------------------------------------
            Purpose: Create one or more new records                                                               
            Notes:                                                                        
    ------------------------------------------------------------------------------*/  
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/CreateCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID CreateCustomer(INPUT-OUTPUT DATASET dsCustomer):           
        
    END METHOD.    
       
    /*------------------------------------------------------------------------------
            Purpose:  Update one or more records                                                                  
            Notes:                                                                        
    ------------------------------------------------------------------------------*/
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/UpdateCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID UpdateCustomer(INPUT-OUTPUT DATASET dsCustomer):           
              
    END METHOD.
       
    /*------------------------------------------------------------------------------
            Purpose:    Delete a record                                                               
            Notes:                                                                        
    ------------------------------------------------------------------------------*/
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/DeleteCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID DeleteCustomer(INPUT-OUTPUT DATASET dsCustomer):                         
               
    END METHOD.

Can you please confirm if this is same with your Business Entity.

By any chance you have added new annotations for the Business Entity class file using Define Service Interface wizard? The potential reason for this behavior would be when you try adding new annotations (say for any new method that got added in the Business Entity) using Define Service Interface wizard. i.e., by default Invoke annotations are selected and when we invoke Finish button without selecting respective operations in the CRUD annotations tab Define Service Interface wizard might replace all annotations with invoke operation.

Invoke Annotation tab in Define Service Interface wizard:

 

CRUD Annotation tab in Define Service Interface wizard:

Thanks and Regards,

Anil Kumar.

All Replies

Posted by agent_008_nl on 05-Dec-2014 08:12

servers\tomcat\webapps\CustomerMobile\static\mobile.json seems wrong also:

{

   "version": "1.0",

   "lastModified": "Fri Dec 05 11:25:17 CET 2014",

   "services": [{

       "name": "CustomerMobile",

       "address": "\/rest\/CustomerMobile",

       "useRequest": true,

       "resources": [{

           "name": "dsCustomer",

           "path": "\/dsCustomer",

           "operations": [

               {

                   "name": "UpdatedsCustomer",

                   "path": "\/UpdatedsCustomer",

                   "type": "invoke",

                   "verb": "put",

                   "params": [{

                       "name": "dsCustomer",

                       "type": "REQUEST_BODY"

                   }]

               },

               {

                   "name": "CreatedsCustomer",

                   "path": "\/CreatedsCustomer",

                   "type": "invoke",

                   "verb": "put",

                   "params": [{

                       "name": "dsCustomer",

                       "type": "REQUEST_BODY"

                   }]

               },

               {

                   "name": "DeletedsCustomer",

                   "path": "\/DeletedsCustomer",

                   "type": "invoke",

                   "verb": "put",

                   "params": [{

                       "name": "dsCustomer",

                       "type": "REQUEST_BODY"

                   }]

               },

               {

                   "name": "ReaddsCustomer",

                   "path": "\/ReaddsCustomer",

                   "type": "invoke",

                   "verb": "put",

                   "params": [{

                       "name": "filter",

                       "type": "REQUEST_BODY"

                   }]

               }

           ]

       }]

   }]

}

Posted by Anil Kumar on 05-Dec-2014 08:26

Hi,
 
By looking at the generated catalog and the wadl files, seems the Business Entity file has all methods with invoke as the operation as below:
 
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/ReadCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID ReadCustomer(
                    
    END METHOD.
        
    /*------------------------------------------------------------------------------
            Purpose: Create one or more new records                                                              
            Notes:                                                                        
    ------------------------------------------------------------------------------*/ 
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/CreateCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID CreateCustomer(INPUT-OUTPUT DATASET dsCustomer):          
        
    END METHOD.   
      
    /*------------------------------------------------------------------------------
            Purpose:  Update one or more records                                                                  
            Notes:                                                                       
    ------------------------------------------------------------------------------*/
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/UpdateCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID UpdateCustomer(INPUT-OUTPUT DATASET dsCustomer):          
             
    END METHOD.
      
    /*------------------------------------------------------------------------------
            Purpose:    Delete a record                                                              
            Notes:                                                                       

Posted by Anil Kumar on 05-Dec-2014 08:42

Hi,

Sorry some how the reply mail didn't reach completely. Following is the complete reply on the same.

By looking at the generated catalog and the wadl files, seems the Business Entity file has all methods with invoke as the operation as below:

@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/ReadCustomer", alias="", mediaType="application/json"). 
    METHOD PUBLIC VOID ReadCustomer(
                    
    END METHOD.
         
    /*------------------------------------------------------------------------------
            Purpose: Create one or more new records                                                               
            Notes:                                                                        
    ------------------------------------------------------------------------------*/  
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/CreateCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID CreateCustomer(INPUT-OUTPUT DATASET dsCustomer):           
        
    END METHOD.    
       
    /*------------------------------------------------------------------------------
            Purpose:  Update one or more records                                                                  
            Notes:                                                                        
    ------------------------------------------------------------------------------*/
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/UpdateCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID UpdateCustomer(INPUT-OUTPUT DATASET dsCustomer):           
              
    END METHOD.
       
    /*------------------------------------------------------------------------------
            Purpose:    Delete a record                                                               
            Notes:                                                                        
    ------------------------------------------------------------------------------*/
    @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
    @progress.service.resourceMapping(type="REST", operation="invoke", URI="/DeleteCustomer", alias="", mediaType="application/json").
    METHOD PUBLIC VOID DeleteCustomer(INPUT-OUTPUT DATASET dsCustomer):                         
               
    END METHOD.

Can you please confirm if this is same with your Business Entity.

By any chance you have added new annotations for the Business Entity class file using Define Service Interface wizard? The potential reason for this behavior would be when you try adding new annotations (say for any new method that got added in the Business Entity) using Define Service Interface wizard. i.e., by default Invoke annotations are selected and when we invoke Finish button without selecting respective operations in the CRUD annotations tab Define Service Interface wizard might replace all annotations with invoke operation.

Invoke Annotation tab in Define Service Interface wizard:

 

CRUD Annotation tab in Define Service Interface wizard:

Thanks and Regards,

Anil Kumar.

Posted by agent_008_nl on 05-Dec-2014 09:12

Thanks Anil! I have to look at it on monday, have the files at my work only. I'll reply the.

Kind regards, Stefan.

Posted by agent_008_nl on 08-Dec-2014 02:26

Thanks again Anil, it works now. I first had to define a mobile service via rightclick on the projectname, select progress openedge / define service interface and after that file / new / mobile service. The uri appeared in the new wadl:

http://localhost:8980/CustomerMobile/rest/CustomerMobile/dsCustomer?filter=

--

Kind regards,

Stefan Houtzager

Houtzager ICT consultancy & development

www.linkedin.com/in/stefanhoutzager

This thread is closed