cancel
Showing results for 
Search instead for 
Did you mean: 

Calling SAP Web Services does not work

Former Member
0 Kudos

Hi,

using this little program, I try to get a simple "Hello World" from a webservice in SAP.

-


require 'soap/rpc/driver'

s = SOAP::RPC::Driver.new('http://server:port/sap/bc/srt/rfc/sap/Z_WS_RUBY/', 'urn:sap-com:document:sap:soap:functions:mc-style')

s.add_method("Z_WS_RUBY", "StringIn" )

p s.Z_WS_RUBY("World")

-


Unfortunately there is an error:

in `parse_local': unknown namespace qualifier: xml (XSD::NS::FormatError)

from D:/rubyy/InstantRails/ruby/lib/ruby/1.8/soap/encodingstyle/soapHandler.rb:532:in `decode_attrs' ETC

In the WebService Recorder I find that the call is going through with request:

-


<?xml version="1.0" encoding="utf-8" ?>

- <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

- <env:Body>

- <n1:Z_WS_RUBY xmlns:n1="urn:sap-com:document:sap:soap:functions:mc-style" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<StringIn xsi:type="xsd:string">World</StringIn>

</n1:Z_WS_RUBY>

</env:Body>

</env:Envelope>

-


but response ist like:

-


- <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">

- <soap-env:Body>

- <soap-env:Fault>

<faultcode>soap-env:Client</faultcode>

<faultstring xml:lang="en">Operation not supported</faultstring>

</soap-env:Fault>

</soap-env:Body>

</soap-env:Envelope>

-


What am I mssing here ?

Any help is appreciated.

Regards

Marcus

Message was edited by:

Marcus Schiffer

Accepted Solutions (0)

Answers (3)

Answers (3)

marcus_schiffer
Active Participant
0 Kudos

Hi,

now I tried with the recommended SAP/WAS package to call a web service in SAP:

This is the little program:

-


require "SAP/WAS"

@was = SAP::WAS.new(:url => "http://myserver:myport/sap/bc/srt/rfc/sap/Z_WS_RUBY",

:lang => "EN",

:client => "800",

:user => "user",

:passwd => "password",

:trace => nil)

iface = @was.ZTestWsRuby

iface.STRINGIN = 'Hello'

@was.call(iface)

puts iface.STRINGOUT

-


Unfortiunately thi sdoes not work and the error is

-


WAS call failed!

ignored element: Feature

ignored element: useFeature

in `call': SAP::WAS::CallException (SAP::WAS::CallException)

-


In SAP I can see the request:

-


<?xml version="1.0" encoding="utf-8" ?>

- <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

- <env:Body>

- <n1:ZTestWsRuby xmlns:n1="urn:sap-com:document:sap:rfc:functions">

<STRINGIN>dd</STRINGIN>

</n1:ZTestWsRuby>

</env:Body>

</env:Envelope>

-


and the response is:

-


- <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">

- <soap-env:Body>

- <soap-env:Fault>

<faultcode>soap-env:Client</faultcode>

<faultstring xml:lang="en">Operation not supported</faultstring>

</soap-env:Fault>

</soap-env:Body>

</soap-env:Envelope>

-


More help on this available ? Any hint is appreciated.

Regards

Marcus

P.S.

I tried the Service from another language (VB) and it works fine.

gregorw
Active Contributor
0 Kudos

Hello Marcus,

have you recorded the Call of the VB program are there any differences in the XML? What exact Web Application Server Version and Service pack do you use?

Regards

Gregor

Former Member
0 Kudos

What version are you running against? sapwas has been tested against 620 and 640 systems certainly as of sapwas-0.11. Inorder for anyone to help you effectively, you need to give version information of ruby/sapwas/SAP .

Additionally - I'm not sure of the syntax that you are using for sapwas - given a service for RFC_READ_REPORT, then an example might be:

@was = SAP::WAS.new(:url => "http://dbw00.bydeluxe.net:8000/sap/bc/srt/rfc/sap/Z_FRFC",

...

:trace => true)

irep = @was.RFC_READ_REPORT

assert( irep.qtab.structure.name == 'D022S' )

irep.program.value = "SAPLGRFC"

irep.call()

  1. access an interface table object

print "Rows of #{irep.program.value}: ", irep.qtab.rows.inspect, "\n"

Try setting this one up and let us know how you go. Also, activate :trace as above, and lets see the output.

Cheers.

marcus_schiffer
Active Participant
0 Kudos

Hi,

I am using SAP WAS Rel. 7.0. SAPWAS is of 0.11.

Couldnt retype your exact example, but I hope it works with my simple program too.

I activated the trace, here the result:

-


ignored element: Feature

ignored element: useFeature

Wire dump:

= Request

! CONNECT TO myserver:myport

! CONNECTION ESTABLISHED

POST /sap/bc/srt/rfc/sap/Z_WS_RUBY?sap-client=800&sap-language=EN HTTP/1.1

SOAPAction: "urn:sap-com:document:sap:rfc:functions"

Content-Type: text/xml; charset=utf-8

Authorization: Basic gzhtfzu=

User-Agent: SOAP4R/1.5.5 (/146, ruby 1.8.6 (2007-03-13) [i386-mswin32])

Date: Thu, 14 Jun 2007 08:14:05 GMT

Content-Length: 332

Host: myserver:myport

<?xml version="1.0" encoding="utf-8" ?>

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<env:Body>

<n1:ZTestWsRuby xmlns:n1="urn:sap-com:document:sap:rfc:functions">

<STRINGIN>dd</STRINGIN>

</n1:ZTestWsRuby>

</env:Body>

</env:Envelope>

= Response

HTTP/1.1 500 Internal Server Error

set-cookie: sap-usercontext=sap-language=EN&sap-client=800; path=/

set-cookie: sap-recorder_sid=%2cc%3dID6-95D8115601C54670F9E2221A00000000--1%2co%3jhggz; path=/; domain=mydomain

content-type: text/xml; charset=utf-8

content-length: 264

sap-srt_id: 20070614/101842/v1.00_final_6.40/466FCFE5847D01C50000000095D81156

server: SAP Web Application Server (1.0;700)

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:Body><soap-env:Fault><faultcode>soap-env:Client</faultcode><faultstring xml:lang="en">Operation not supported</faultstring></soap-env:Fault></soap-env:Body></soap-env:Envelope>

-


The call does not ecven go through to the Function Module in SAP.

Here is the call that worked from my VB Program:

<?xml version="1.0" encoding="utf-8" ?>

- <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

- <env:Body>

- <n1:ZTestWsRuby xmlns:n1="urn:sap-com:document:sap:soap:functions:mc-style" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<STRINGIN xsi:type="xsd:string">wert</STRINGIN>

</n1:ZTestWsRuby>

</env:Body>

</env:Envelope>

gregorw
Active Contributor
0 Kudos

Hello Marcus,

can you post the source of the RFC Enabled Function module you published as a web service? Have you published the Function Goup or the Function Module alone?

Regards

Gregor

marcus_schiffer
Active Participant
0 Kudos

Hi,

the function is very simple, just for test

-


FUNCTION Z_TEST_WS_RUBY.

*"----


""Lokale Schnittstelle:

*" IMPORTING

*" VALUE(STRINGIN) TYPE STRING

*" EXPORTING

*" VALUE(STRINGOUT) TYPE STRING

*"----


concatenate stringin 'World' into stringout.

ENDFUNCTION.

-


and is published alone.

Regards

Marcus

Former Member
0 Kudos

Hi -

I've created this in a 640 system (BW), and it runs OK. There is a problem with the response in that it comes back garbled because of an edge case in SOAP4R. When SOAP4R gets a single parameter result it returns a scalar value, and not an array, but this would not have shown a SOAP fault like you are seeing - you would have got a number instead of a string value for STRINGOUT, most likely. This particular problem I've fixed in sapwas-0.12, which is available for download now. The test that I used was:

require "lib/SAP/WAS"

require 'test/unit'

require 'test/unit/assertions'

class SAPTest < Test::Unit::TestCase

def setup

@was = SAP::WAS.new(:url => "http://dbw00.bydeluxe.net:8000/sap/bc/srt/rfc/sap/Z_TEST_WS_RUBY",

:lang => "EN",

...

:trace => false)

end

def test_BASIC_00010_test

  1. look up the interface definition for an RFC

i = @was.Z_TEST_WS_RUBY

i.stringin.value = "Hello, "

i.call()

print "STRINGOUT: #{i.stringout.value}\n"

end

def teardown

end

end

Cheers.

marcus_schiffer
Active Participant
0 Kudos

Hi,

I am still struggeling. The new SAPWAS is installed, the od deinstalled and I tried the coding you provided. however, the error is still the same. Meanwhile I tried again with the original version

-


s = SOAP::RPC::Driver.new('http://myserver:myport/sap/bc/srt/rfc/sap/Z_WS_RUBY', 'urn:sap-com:document:sap:soap:functions:mc-style')

s.add_method("ZTestWsRuby", "STRINGIN")

p s.ZTestWsRuby("Hello")

-


and it worked fine (in the first place I used the wrong service name, SAP changes this in the WSDl description on automatic generation to a version without underscores).

The soap call is exactly as the VB example.

On debugging your example I found that namespace is urn:sap-com:document:sap:soap:functions whereas in the running example it is

urn:sap-com:document:sap:soap:functions:mc-style

May this be the reason for failure ?

Still appreciate any help.

Regards

Marcus

marcus_schiffer
Active Participant
0 Kudos

Hi,

just verified the urn problem. When changing to urn:sap-com:document:sap:soap:functions the above little example also fails.

Debugging the abap tells me that somewhere in the CL_SOAP_APPLICATION_SERVER class a method CHECK_OPERATION is called. This method fails if the call does not use the mc-style extension.

How can the namespace be provided in theh SAPWAS ?

Regards

Marcus

marcus_schiffer
Active Participant
0 Kudos

Hi,

finally I found the reason and a cure.

The reason is, that on generation of the web service from the function module i checked the "mapping" feauture in the wizard. This forces SAP to erase all underscores and to use the urn with extension mc-style.

As soon as the service is generated without the mapping option, everything works as designed. However, as the example abaove shows, a call with an explicit namespace parameter can also go through and sometimes the mapping is a usefull feature. So mayby you think of including it in the pacakage.

Regards

Marcus

former_member206397
Contributor
0 Kudos

Hi Gregor,

I read the posted message and reply from you. I have faced a new problem when calling WS from Excel.

I have created a WS from CAF which has one method and the method takes a list (a table) of structure as an input and returns a string as output. The structure contains three fields

such as

medPlace -- String

publictn - String

amount - long

This WS is working fine when I am testing from WS Nevigator.

Now I have imported the WS in Excel and now the data types are like

medPlace -- String

publictn - String

amount - double

My requirement is to send the multiple row of the Excel to the WS at a time( I mean as a List). So when I have executed it first time I got error like “deserialisation error”. But I got an article (SAP Web Services and Microsoft Office: How to Create Simple Composite Applications ) by Marcus Schiffer and that problem is resolved.

But Now I am getting the error like ......Client:Type conversion failure for element eXLSTRUCT0 HRESULT=0x80020005: Type mismatch. - Client:Unspecified client error. HRESULT=0x80020005: Type mismatch.

eXLSTRUCT0 - This is my structure name in input.

Can you please help me to solve this issue.

Thanks in advance

Chandan

gregorw
Active Contributor
0 Kudos

Hello Chandan,

have you tried SAP Note 1009109 - Analyzing Web service problems using the ICF recorder to analyze the problem?

Regards

Gregor

marcus_schiffer
Active Participant
0 Kudos

Thanks for the hint !

I will try it out immediately.

However, where ist the problem with the above code ? SOA is about using easy standards, so I would expect SAP to work with standard Web Service coding in Ruby.

Help is still appreciated.

Regards

Marcus

Former Member
0 Kudos

I think that is the utopia of WS*, but the reality is somewhat different.

Cheers.

Former Member
0 Kudos

Hi - sapwas allready does this, and works with sap4rails => http://raa.ruby-lang.org/project/sapwas

Cheers.