+ Start a Discussion
AMIT KUMAR 73AMIT KUMAR 73 

Custom Web Service to return list of records in accounts object

Hi,

my requirement is to send all records (Work Order - custom object) to some third part app by exposing a custom WSDL file.
I developer the below code, which compiles fine in salesforce but gives an error while testing the same in SOAP UI tool.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
global class TestWOStatus{
    webservice static LIST<Work_Order__c> getWorkOrder(){
         LIST<Work_Order__c> wo = [SELECT ID,account__c,Product__c,Order_Type__c,Order_Status__c,Billing_Type__c,Closed_By__c FROM Work_Order__c];
         return wo;
       }
      
       /*webservice static String getWorkOrder(){
         return 'HELLO';*/
       }
}
-------------------------------------------------------------------------------------------------------------------------------------------------------

Any suggestions will be highly appreciated.
Best Answer chosen by AMIT KUMAR 73
pconpcon
Glad to see you got that working.  I prefer to work with my return objects being just primatives in salesforce and then mapping them to the backend object.  For example with your code I would do

global class TestWOStatus {
     global class WorkOrder {
          global String Id;
          global String accountId;
          global String productId;
          global String orderType;
          global String orderStatus;
          global String billingType;
          global String closedById;

          public WorkOrder() {}

          public WorkOrder(Work_Order__c order) {
               this.id = order.Id;
               this.accountId = order.Account__c;
               this.productId = order.Product__c;
               this.orderType = order.Order_Type__c;
               this.orderStatus = order.Order_Status__c;
               this.billingType = order.Billing_Type__c;
               this.closedById = order.Closed_By__c;
          }
     }

     webservice static List<WorkOrder> getWorkOrder() {
          List<WorkOrder> result = new List<WorkOrder>();

          for (Work_Order__c order: [
               select Account__c,
                    Product__c,
                    Order_Type__c,
                    Order_Status__c,
                    Billing_Type__c,
                    Closed_By__c
               from Work_Order__c
               top 2
          ]) {
               result.add(new WorkOrder(order));
          }

          return result;
     }
}
NOTE: This code has not be tested and may contain typographical or logical errors

By making it it's own class with member variables it allows you to change the backing data without having to change your WSDL consumer

All Answers

pconpcon
What error do you get from SoapUI?
AMIT KUMAR 73AMIT KUMAR 73
Hi pcon,

Thanks for your reply. First of all let me thanks you i have gone through lot of blogs/articles posted by you which was excellent for the beginers on SFDC. I found the issue with my custom web service call. Below is the updated code which runs without any issue.

User-added image
pconpcon
Glad to see you got that working.  I prefer to work with my return objects being just primatives in salesforce and then mapping them to the backend object.  For example with your code I would do

global class TestWOStatus {
     global class WorkOrder {
          global String Id;
          global String accountId;
          global String productId;
          global String orderType;
          global String orderStatus;
          global String billingType;
          global String closedById;

          public WorkOrder() {}

          public WorkOrder(Work_Order__c order) {
               this.id = order.Id;
               this.accountId = order.Account__c;
               this.productId = order.Product__c;
               this.orderType = order.Order_Type__c;
               this.orderStatus = order.Order_Status__c;
               this.billingType = order.Billing_Type__c;
               this.closedById = order.Closed_By__c;
          }
     }

     webservice static List<WorkOrder> getWorkOrder() {
          List<WorkOrder> result = new List<WorkOrder>();

          for (Work_Order__c order: [
               select Account__c,
                    Product__c,
                    Order_Type__c,
                    Order_Status__c,
                    Billing_Type__c,
                    Closed_By__c
               from Work_Order__c
               top 2
          ]) {
               result.add(new WorkOrder(order));
          }

          return result;
     }
}
NOTE: This code has not be tested and may contain typographical or logical errors

By making it it's own class with member variables it allows you to change the backing data without having to change your WSDL consumer
This was selected as the best answer
AMIT KUMAR 73AMIT KUMAR 73
Thanks pcon,

will definately follow your advice. 
AMIT KUMAR 73AMIT KUMAR 73
Hi Pcon,

Is there any way to generate schema for the above wsdl in salesforce.
When i import the wsdl in (JDeveloper) it's not showing the schemas for the above wsdl.
Is there any way to achieve this?

pconpcon
I don't know honestly.  If it imports into SoapUI without an issue then it might be an issue with JDeveloper and I've never used that product.
AMIT KUMAR 73AMIT KUMAR 73
No Probs. Will check this as well.
pconpcon
I just realized that the declaration of the WorkOrder is wrong, and the system won't let me edit it.  It should be:

global class WorkOrder {
          WebService String Id;
          WebService String accountId;
          WebService String productId;
          WebService String orderType;
          WebService String orderStatus;
          WebService String billingType;
          WebService String closedById;

          public WorkOrder() {}

          public WorkOrder(Work_Order__c order) {
               this.id = order.Id;
               this.accountId = order.Account__c;
               this.productId = order.Product__c;
               this.orderType = order.Order_Type__c;
               this.orderStatus = order.Order_Status__c;
               this.billingType = order.Billing_Type__c;
               this.closedById = order.Closed_By__c;
          }
     }

that should make it visible in the WSDL exported via the SFDC UI
AMIT KUMAR 73AMIT KUMAR 73
How do we write test class for the above apex code to meet all covergae criteria in salesforce?
pconpcon
It's the same as writing any other test class.  You should just create your Work_Order__c object, then call TestWOStatus.getWorkOrder() and do system.assertEquals against the resultant fields to make sure you get the expected data back.
AMIT KUMAR 73AMIT KUMAR 73
Hi,

Gone a step ahead and instead of hardcoding query wanted to create it dynamically from excel in static resource (SFDC).
Unable to achieve this logic. Is it possible ? or any approach need to be changed?

PC_WorkOrder

Apex Code:

public class DynaWSQuery{
    String result = getXml('PC_SVMAX');
    public static String getXml(String staticResourceName) {
        StaticResource defaultResource  = [select Body from StaticResource where Name = :staticResourceName];
        //String temp = EncodingUtil.base64Encode(sr.Body);       
        //System.debug('-------------->>'+[select Body from StaticResource where Name = :staticResourceName]);
        String contentFile = EncodingUtil.base64Encode(defaultResource.Body);
        String[] filelines = contentFile.split('\n');
        System.debug('>>>>>>>>>>>>>>>>>>:'+filelines);
        for (Integer i=1;i<filelines.size();i++)
        {
             //object_to_Create__c temp = object_to_Create__c();
          //String[] inputvalues = filelines[i].split(',');
       //temp.Field1__c = inputValues[0];
       //temp.Field2__c = inputValues[1];
       //defaults.add(temp);
       System.debug('Row['+i+']:'+filelines[i]);

        }
     return 'Sucess';
    }
}

Debug Log:

31.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
Execute Anonymous: DynaWSQuery.getXml('PC_WorkOder');
14:31:35.038 (38739016)|EXECUTION_STARTED
14:31:35.038 (38757402)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
14:31:35.039 (39353866)|SYSTEM_MODE_ENTER|false
14:31:35.044 (44552633)|METHOD_ENTRY|[1]|01p90000005UKAq|DynaWSQuery.DynaWSQuery()
14:31:35.044 (44580572)|METHOD_EXIT|[1]|DynaWSQuery
14:31:35.044 (44635738)|METHOD_ENTRY|[1]|01p90000005UKAq|DynaWSQuery.getXml(String)
14:31:35.044 (44952885)|SOQL_EXECUTE_BEGIN|[4]|Aggregations:0|select Body from StaticResource where Name = :tmpVar1
14:31:35.049 (49979482)|SOQL_EXECUTE_END|[4]|Rows:1
14:31:35.050 (50247952)|SYSTEM_METHOD_ENTRY|[7]|system.EncodingUtil.base64Encode(Blob)
14:31:35.050 (50534962)|SYSTEM_METHOD_EXIT|[7]|system.EncodingUtil.base64Encode(Blob)
14:31:35.050 (50578152)|SYSTEM_METHOD_ENTRY|[8]|String.split(String)
14:31:35.050 (50989082)|SYSTEM_METHOD_EXIT|[8]|String.split(String)
14:31:35.051 (51042867)|SYSTEM_METHOD_ENTRY|[9]|String.valueOf(Object)
14:31:35.051 (51136611)|SYSTEM_METHOD_EXIT|[9]|String.valueOf(Object)
14:31:35.051 (51177828)|SYSTEM_METHOD_ENTRY|[9]|System.debug(ANY)
14:31:35.051 (51187693)|USER_DEBUG|[9]|DEBUG|>>>>>>>>>>>>>>>>>>:(UEsDBBQABgAIAAAAIQCq91ikegEAABQGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAhALAKZiiZAQAASwMAABAAAAAAAAAAAAAAAAAA8R0AAGRvY1Byb3BzL2FwcC54bWxQSwECLQAUAAYACAAAACEAvPlstu4GAACAHQAAJwAAAAAAAAAAAAAAAADAIAAAeGwvcHJpbnRlclNldHRpbmdzL3ByaW50ZXJTZXR0aW5nczEuYmluUEsBAi0AFAAGAAgAAAAhAPxelnRNAQAAcwIAABEAAAAAAAAAAAAAAAAA8ycAAGRvY1Byb3BzL2NvcmUueG1sUEsFBgAAAAAOAA4AsgMAAHcqAAAAAA==)
14:31:35.051 (51283211)|SYSTEM_METHOD_EXIT|[9]|System.debug(ANY)
14:31:35.051 (51323721)|SYSTEM_METHOD_ENTRY|[10]|LIST<String>.size()
14:31:35.051 (51358786)|SYSTEM_METHOD_EXIT|[10]|LIST<String>.size()
14:31:35.051 (51381326)|METHOD_EXIT|[1]|01p90000005UKAq|DynaWSQuery.getXml(String)
14:31:35.051 (51401171)|SYSTEM_MODE_EXIT|false
14:31:35.092 (51450628)|CUMULATIVE_LIMIT_USAGE
14:31:35.092|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 1 out of 100
  Number of query rows: 1 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 10000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 10
  Number of Mobile Apex push calls: 0 out of 10

14:31:35.092|CUMULATIVE_LIMIT_USAGE_END

14:31:35.051 (51483425)|CODE_UNIT_FINISHED|execute_anonymous_apex
14:31:35.054 (54459742)|EXECUTION_FINISHED
    
pconpcon
I would recommend against doing something like this.  You will still need to have each field enumerated in your WebService class to have it show up in your WSDL.  You could do something like returning a JSON object as one of your fields, but that is very much against how XML is suppose to work.  If you want to make it so you don't have to change query every time you added a new field you could do something like the code below, but even that I would have to recommend against.

global class TestWOStatus {
     global class WorkOrder {
          WebService String Id;
          WebService String accountId;
          WebService String productId;
          WebService String orderType;
          WebService String orderStatus;
          WebService String billingType;
          WebService String closedById;

          public static Map<String, String> fieldMap = new Map<String, String>{
               'Id' => 'Id,
               'accountId' => 'Account__c',
               'productId' => 'Product__c',
               'orderType' => 'Order_Type__c',
               'orderStatus' => 'Order_Status__c',
               'billingType' => 'Billing_Type__c',
               'closedById' => 'Closed_By__c'
          };

          public WorkOrder() {}

          public WorkOrder(Work_Order__c order) {
               this.id = order.get(fieldMap.get('Id'));
               this.accountId = order.get(fieldMap.get('accountId'));
               this.productId = order.get(fieldMap.get('productId'));
               this.orderType = order.get(fieldMap.get('orderType'));
               this.orderStatus = order.get(fieldMap.get('orderStatus'));
               this.billingType = order.get(fieldMap.get('billingType'));
               this.closedById = order.get(fieldMap.get('closedById'));
          }
     }

     webservice static List<WorkOrder> getWorkOrder() {
          List<WorkOrder> result = new List<WorkOrder>();
          String query = 'select ' + String.join(fieldMap.values(), ',') + 'from Work_Order__c top 2';

          for (sObject obj: Database.query(query)) {
               Work_Order__c order = (Work_Order__c)(obj);
               result.add(new WorkOrder(order));
          }

          return result;
     }
}


Sunil DwarakanathSunil Dwarakanath
Hi,
I am writing a web service for fetching a custom object value in the same type as Amit has mentioned in the screenshot.
Can you please let me know how to access result for the same after uploading WSDL into salesforce.