consuming web service with c#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sangweb
    New Member
    • Feb 2008
    • 2

    consuming web service with c#

    Ho do I consume the web service that has the following requirement? I add the web reference and create an instance but I am not sure how I can assign the value to each of the tag?

    testws.webserv ws = new testws();

    ws.batch.report[0].header="test 1";

    am I doing this correctly? when I try to call the testws.soapmeth od(), it expect the batch object and this is where I am stuck. TIA.

    sample data

    <batch>
    <report>
    <header>test 1</header>
    <detail>
    <line>1</line>
    <line>2</line>
    </detail>
    </report>
    <report>
    <header>test 1=2</header>
    <detail>
    <line>1</line>
    <line>2</line>
    </detail>
    </report>
    </batch>
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Is it throwing any exception or returning any error codes?

    Its been a while since i touched web services, but have you created soapmethod in the webservice?

    Comment

    • sangweb
      New Member
      • Feb 2008
      • 2

      #3
      ok, so I think the problem is setting the class with values, basically, I need to create a class, withing it, it has an array class but when ever I try to set it, I get
      "Object reference not set to an instance of an object"

      Here is my code:
      Code:
      private void button1_Click(object sender, EventArgs e)
              {       
                  global::eClaims.slb.com.eGatews.wsdConcurEclaim_New_Service egws = new global::eClaims.slb.com.eGatews.wsdConcurEclaim_New_Service();
                  global::eClaims.slb.com.eGatews.ERA_BATCH era_bch = new global::eClaims.slb.com.eGatews.ERA_BATCH();
                  global::eClaims.slb.com.eGatews.HEADER era_hdr = new global::eClaims.slb.com.eGatews.HEADER();
      
                  global::eClaims.slb.com.eGatews.eGateResponse era_resp = new global::eClaims.slb.com.eGatews.eGateResponse();
                  
                  global::eClaims.slb.com.eGatews.LINE_ITEM[] era_line = new global::eClaims.slb.com.eGatews.LINE_ITEM[3];
                  global::eClaims.slb.com.eGatews.ERA_REPORT[] era_rpt = new global::eClaims.slb.com.eGatews.ERA_REPORT[1];
      
                  //batch
                  
                  era_bch.APP_NAME = "eClaims";
                  era_bch.BATCH_ID = "1";
                  era_bch.SYSTEM = "SAP";
      
                  //header
                  era_hdr.EMP_ID = "01140417";
                  era_hdr.FIRST_NAME = "Sang";
                  era_hdr.LAST_NAME = "Le";
                  era_hdr.BUS_AREA = "Bus Area";
                  era_hdr.RPT_SUB_DATE = "02-FEB-2008";
                  era_hdr.RPT_NAME = "Expense Report";
                  era_hdr.COMPANY = "SLB";
                  era_hdr.CC = "8035";
                  era_hdr.PROJECT = "eClaims";
                  era_hdr.RPT_DESC = "exp description";
                  era_hdr.APPRV_DATE = "20-FEB-2008";
                  era_hdr.CURR_ALPHA = "USD";
                  era_hdr.CURR_NUM = "1";
                  era_hdr.RPT_POLICY = "T&ampE NAM";
                  era_hdr.LEDGER = "LEDGER";
                  era_hdr.ASSIGNMENT = "assignment";
                  era_hdr.INTERFACE_DATE = "25-FEB-2008";
      
                  //detail data
                  /*
                  for (int i = 0; i < 3; i++)
                  {
                      era_line[i].RPE_KEY = "100" + i;
                      era_line[i].EXP_TYPE = "Hotel";
                      era_line[i].TRANS_DATE = "01-JAN-2008";
                      era_line[i].ENTRY_DESC = "Entry Descriptions";
                      era_line[i].ENTRY_CC = "8035";
                      era_line[i].ENTRY_PROJ = "Project NUmber";
                      era_line[i].ENTRY_INTORD = "Internal Order";
                      era_line[i].TAX_AMT = "";
                      era_line[i].TAX_CODE = "";
                      era_line[i].ACCNT_CODE = "12345";
                      era_line[i].SUB_ACCNT = "67890";
                      era_line[i].DEB_CREDIT = "DR";
                      era_line[i].AMOUNT = "500";
                      era_line[i].NET_TAX_AMT = "";
                      era_line[i].CC_NUM = "123456789123";
                      era_line[i].PAYER = "SLB";
                      era_line[i].PAYEE = "Sang Le";
                  }
                  */
                  era_rpt[0].HEADER = era_hdr; <-- error here
                  //era_rpt[0].DETAIL = era_line; <--error here also when uncomment
      
                  era_bch.ERA_REPORT[0] = era_rpt;
               
                  //testRepor[0].field1 = "";
               //era_bch.ERA_REPORT = testRepor;
      
                //  egws.ConcurEclaimRequestSOAP();

      Comment

      Working...