cancel
Showing results for 
Search instead for 
Did you mean: 

Consume SAP Web Service (in C#)

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (1)

Answers (1)

hasanajsh
Active Contributor
0 Kudos

Hi,

Please have a look at  1737707 - .Net client loses connection to Application Server

Try setting the parameter icm/HTTP/expect_100_close_on_error to false and check.

Regards

Former Member
0 Kudos

Thank you for your answer. I already contacted our system operator for setting the parameter.

Regards

Miran

Former Member
0 Kudos

Hello,

I was trying to solve the problem according to your kind advice, but

1. the note 1737707 cannot be applied on our Kernel version (there is no          parameter icm/HTTP/expect_100_close_on_error)

2. workaround does not work:

            Cursor.Current = Cursors.WaitCursor;

            var req = (HttpWebRequest)WebRequest.Create("http://guediserr.durs.si:8010/sap/bc/srt/wsdl/flv_10002A111AD1/bndg_url/sap/bc/srt/rfc/sap/zws_sqrt/...");

            req.ServicePoint.Expect100Continue = false;

            req.KeepAlive = false;

            req.ProtocolVersion = HttpVersion.Version10;

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

            root.Credentials = new NetworkCredential("GORENMI1", "tlaxcala3");

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

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

            x.Number = 25;

            y = root.ZSqrt(x);

            textBox9.Text = y.Result.ToString();

            Cursor.Current = Cursors.Default;

I get an error

Web service processing error; more details in the web service error log on provider side (UTC timestamp 20150220075532; Transaction ID 54E4BD639123DA34E10000000A04063D)

I cannot find no other help, that's why I am writing to you. Can you help me ?

thanks in advance

best regards

Miran

hasanajsh
Active Contributor
0 Kudos

Hi,

You have not given any info about your Kernel.

Anyway, do not worry if the system is complaining about not knowing the parameter (in RZ10). This happens sometimes with some parameters, although they can be applied. Just give this option a try.

Regards