Quantcast
Channel: SCN : All Content - SAP NetWeaver Application Server
Viewing all articles
Browse latest Browse all 2997

Consume SAP Web Service (in C#)

$
0
0

1. I created Web Service ZWS_SQRT, based on WSDL, which uses function module Z_SQRT, which calculates the square root of a given input parameter:

 

FUNCTION Z_SQRT.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(NUMBER) TYPE  F

*"  EXPORTING

*"     VALUE(RESULT) TYPE  F

*"  EXCEPTIONS

*"      NEGATIVE_ARGUMENT

*"----------------------------------------------------------------------

if number >= 0.

   data  outNumber type f.

   CALL METHOD cl_foev_builtins=>square_root

   EXPORTING

     im_number = number

   IMPORTING

     ex_result = outNumber.

   result = outNumber.

else.

   raise negative_argument.

endif.

 

ENDFUNCTION.

 

2. Then, in SOAMANAGER transaction I configured the service. The service works well locally in SE80 transaction

 

3. In the last step, I made a C# program in Visual Studio, which calls the service. The program is correct (WebReference is created web service reference):

 

            WebReference.ZWS_SQRT root = new WebReference.ZWS_SQRT();

            root.Credentials = new NetworkCredential("<username>", "<password>");

            WebReference.ZSqrt x = new WebReference.ZSqrt();

            WebReference.ZSqrtResponse y = new WebReference.ZSqrtResponse();

            y = root.ZSqrt(x);

 

But the problem is that, when calling the service, I usualy (but not always) get an error "The request was aborted: The request was canceled". If I wrap the statement y = root.ZSqrt(x) in while loop like this:

 

int i=0;

Boolean b=true;

while (b)

{

     try

     {

          y = root.ZSqrt(x);

          b=false;

     }

     catch

     {

     }

     i++;

if (i==20) break;

}

 

the program works, but this surely is not the right solution.

 

So, the error must somewhere in Web Service Configuration of SOA Management (the picture is below, surely it is not enough, but I must start somewhere).

 

Please help me to solve this.

 

Thanks in advance

 

Miran


Viewing all articles
Browse latest Browse all 2997

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>