cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with SDN RSS Feed - part 1

Former Member
0 Kudos

Hi all, this is the first question I have regarding the SDN RSS Feed and it's processing. I have followed Brian's weblog 'RSS = HttpClient + XML + XSLT' (link: /people/brian.mckellar/blog/2004/06/25/bsp-programming-rss-httpclient-xml-xslt). When testing this example I run into a problem when executing the following commands:

node = element->find_from_name( name = 'creator' ).

<blog>-creator = node->get_value( ).

node = element->find_from_name( name = 'date' ).

<blog>-date = node->get_value( ).

Both values seem to be empty resulting in a HTTP_COMMUNICATION_FAILURE. When I comment these lines out the example runs correctly. Checking the actual RSS Feed, http://weblogs.sdn.sap.com/pub/q/weblog_rss_topic?x-topic=24&x-ver=1.0, there are entries for dc:creator and dc:date, so I changed my code accordingly but no success. Any idea what is causing this issue? Thanks, Tiest

Accepted Solutions (1)

Accepted Solutions (1)

former_member181879
Active Contributor
0 Kudos

I fail to see how these values could result in a HTTP comms error. But it has been a long time since that code. Let us keep the communication in one thread. We await your cleaned up code (max 25-50 lines) to see where you are now.

Former Member
0 Kudos

Brian, as discussed attached a test programm that shows the first error I am unable to understand.... Hope this makes it easier for you all to help me understand what is causing this issue. Thanks in advance, Tiest.

REPORT ZBSP_FAQ_RSSTST

DATA: url TYPE STRING,

http_client TYPE REF TO IF_HTTP_CLIENT,

return_code TYPE I,

content TYPE STRING.

url = 'http://weblogs.sdn.sap.com/pub/q/weblog_rss_topic?x-topic=24&x-ver=1.0'.

  • url = 'http://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0'.

cl_http_client=>create_by_url( EXPORTING url = url

IMPORTING client = http_client ).

http_client->send( ).

http_client->receive( ).

http_client->response->get_status( IMPORTING code = return_code ).

content = http_client->response->get_cdata( ).

http_client->close( ).

  • Parse response into XML Document

TYPE-POOLS: ixml.

DATA: ixml TYPE REF TO if_ixml,

streamFactory TYPE REF TO if_ixml_stream_factory,

istream TYPE REF TO if_ixml_istream,

parser TYPE REF TO if_ixml_parser,

document TYPE REF TO if_ixml_document.

IF content CS '<!DOCTYPE' AND content CS ']>'.

DATA dummy type string.

SPLIT content AT '<!DOCTYPE' INTO dummy content.

SPLIT content AT ']>' INTO dummy content.

ENDIF.

ixml = cl_ixml=>create( ).

streamFactory = ixml->create_stream_factory( ).

istream = streamFactory->create_istream_cstring( content ).

document = ixml->create_document( ).

parser = ixml->create_parser( stream_factory = streamFactory

istream = iStream

document = document ).

parser->set_normalizing( ).

parser->set_validating( mode = if_ixml_parser=>co_no_validation ).

parser->parse( ).

  • Define table for BSP Output

TYPES: BEGIN OF t_blog,

title TYPE string,

link TYPE string,

description TYPE string,

creator TYPE string,

date TYPE string,

END OF t_blog,

t_blogs TYPE TABLE OF t_blog.

DATA: blogs type t_blogs.

FIELD-SYMBOLS: <blog> type t_blog.

- Find all the <item> tags -

DATA: collection TYPE REF TO if_ixml_node_collection,

node TYPE REF TO if_ixml_node,

element TYPE REF TO if_ixml_element,

index TYPE i.

collection = document->get_elements_by_tag_name( name = 'item' ).

WHILE index < collection->get_length( ).

APPEND INITIAL LINE TO blogs ASSIGNING <blog>.

node = collection->get_item( index ).

element ?= node->query_interface( ixml_iid_element ).

index = index + 1.

node = element->find_from_name( name = 'title' ).

<blog>-title = node->get_value( ).

node = element->find_from_name( name = 'link' ).

<blog>-link = node->get_value( ).

node = element->find_from_name( name = 'description' ).

<blog>-description = node->get_value( ).

<b>- Activating these two lines results in a shortdump, no idea what is causing this problem -</b>

node = element->find_from_name( name = 'creator' ).

<blog>-creator = node->get_value( ).

node = element->find_from_name( name = 'date' ).

<blog>-date = node->get_value( ).

ENDWHILE.

LOOP AT blogs ASSIGNING <blog>.

write: / 'title:', 14 <blog>-title.

write: / 'link:', 14 <blog>-link.

write: / 'description:', 14 <blog>-description.

write: / 'creator:', 14 <blog>-creator.

write: / 'date:', 14 <blog>-date.

write: /.

ENDLOOP.

Message was edited by: Tiest van Gool

Former Member
0 Kudos

Hi Tiest,

The link you are trying to get gives me an error when I try as well but the other works.

Former Member
0 Kudos

Mmm, even more odd, this morning the link worked properly, lemme see what happend. Please try the pogram again with the new link http://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0'.

I have updated the program accordingly, please have a look whether or not you guys also receive an error. Tiest

Former Member
0 Kudos

Man that is confusing I need to compare this to the code I use in other places. For some reason trying to grab those last two entries blows up it's almost as though it can't find them like the string is too long.


REPORT  ZSDN_TIEST                                                  .

DATA: url TYPE STRING,
      http_client TYPE REF TO IF_HTTP_CLIENT,
      return_code TYPE I,
      content TYPE STRING.

*url = 'http://weblogs.sdn.sap.com/pub/q/weblog_rss_topic?x-topic=24&x-ver=1.0'.
url = 'http://weblogs.sdn.sap.com/pub/q/weblogs_rss?x-ver=1.0'.

cl_http_client=>create_by_url(
  EXPORTING url = url
  IMPORTING client = http_client ).

http_client->send( ).
http_client->receive( ).
http_client->response->get_status( IMPORTING code = return_code ).

content = http_client->response->get_cdata( ).

http_client->close( ).

* Parse response into XML Document
TYPE-POOLS: ixml.

DATA: ixml TYPE REF TO if_ixml,
      streamFactory TYPE REF TO if_ixml_stream_factory,
      istream TYPE REF TO if_ixml_istream,
      parser TYPE REF TO if_ixml_parser,
      document TYPE REF TO if_ixml_document.

IF content CS '<!DOCTYPE' AND content CS ']>'.
  DATA dummy type string.
  SPLIT content AT '<!DOCTYPE' INTO dummy content.
  SPLIT content AT ']>' INTO dummy content.
ENDIF.

ixml = cl_ixml=>create( ).
streamFactory = ixml->create_stream_factory( ).
istream = streamFactory->create_istream_cstring( content ).
document = ixml->create_document( ).
parser = ixml->create_parser( stream_factory = streamFactory
istream = iStream
document = document ).
parser->set_normalizing( ).
parser->set_validating( mode = if_ixml_parser=>co_no_validation ).
parser->parse( ).

* Define table for BSP Output
TYPES: BEGIN OF t_blog,
          title TYPE string,
          link TYPE string,
          description TYPE string,
          creator TYPE string,
          date TYPE string,
       END OF t_blog,
t_blogs TYPE TABLE OF t_blog.

DATA: blogs type t_blogs.

FIELD-SYMBOLS: <blog> type t_blog.

*- Find all the <item> tags -*
DATA: collection TYPE REF TO if_ixml_node_collection,
      node TYPE REF TO if_ixml_node,
      element TYPE REF TO if_ixml_element,
      index TYPE i.

collection = document->get_elements_by_tag_name( name = 'item' ).
WHILE index < collection->get_length( ).

  APPEND INITIAL LINE TO blogs ASSIGNING <blog>.
  node = collection->get_item( index ).
  element ?= node->query_interface( ixml_iid_element ).
  index = index + 1.

  node = element->find_from_name( name = 'title' ).
  <blog>-title = node->get_value( ).

  node = element->find_from_name( name = 'link' ).
  <blog>-link = node->get_value( ).

  node = element->find_from_name( name = 'description' ).
  <blog>-description = node->get_value( ).

*- Activating these two lines results in a shortdump, no idea what is causing this problem -*
*  node = element->find_from_name( name = 'creator' ).
*  <blog>-creator = node->get_value( ).

*  node = element->find_from_name( name = 'date' ).
*  <blog>-date = node->get_value( ).

ENDWHILE.

LOOP AT blogs ASSIGNING <blog>.
  write: / 'title:', 14 <blog>-title.
  write: / 'link:', 14 <blog>-link.
  write: / 'description:', 14 <blog>-description.
  write: / 'creator:', 14 <blog>-creator.
  write: / 'date:', 14 <blog>-date.
  write: /.
ENDLOOP.

Former Member
0 Kudos

Craig, thanks in advance for your help on this matter, I am looking into this myself as well. If you find something, let me know.

Brian, can you have a look at this issue as well since I hope, I delivered my question in a more preferred matter. Thanks, Tiest

Former Member
0 Kudos

Craig or Brian, help me here!!! Tiest

-


Message was edited by: Brian McKellar

NO! At the end of the day you are responsible for helping yourself. It is 23:30, I had a long day, and my family is all already in bed. Any help here is only a personal basis and a best effort. This is something which should be very clear to you, and respected and appreciated as such. In return, we expect you to one day to also answer a question or two.

Former Member
0 Kudos

I'm still playing around here but the only thing I can think of is that the content coming in is just too big the node I mean and it's not grabbing the end of it.

former_member181879
Active Contributor
0 Kudos

  node = element->find_from_name( name = 'creator' ).
  <blog>-creator = node->get_value( ).
  node = element->find_from_name( name = 'date' ).
  <blog>-date = node->get_value( ).

Reading this code, we have to assume that element reference is still correct. It used previously as well. So what happens is that the find_from_name fails, and returns a NULL node. The next line uses the NULL reference straight into RABAX. Of course, your could add a "IF node IS NOT INITIAL" into that code. Should probably have been done.

Let us look at the XML in this area:

<description>A note on placement...</description>

<dc:creator>Kevin Liu</dc:creator>

The difference between the <description> and <creator> elements are of course the namespace dc: we silently dropped. Very bad. Seriously recommended is reading a little about XML, and specifically about the iXML implementation. The API is very good. It deserves to be read!

I have changed your code as follows:


  node = element->find_from_name<b>_ns</b>( 
     name = 'creator' 
     <b>uri  = 'http://purl.org/dc/elements/1.1/'</b> ).
  <blog>-creator = node->get_value( ).
  node = element->find_from_name<b>_ns</b>( 
     name = 'date' 
     <b>uri  = 'http://purl.org/dc/elements/1.1/'</b> ).
  <blog>-date = node->get_value( ).

Then the report worked perfectly.

brian

---

Message was edited by: Brian McKellar

A final remark. It could be that the XML of the RSS feed was changed since the time the weblogs were written. This is what I would suspect.

Former Member
0 Kudos

I didn't even notice that until just now. However not all the RSS feeds have that or at least not the last ones I checked a few days ago with older code. I'll have to double check.

Former Member
0 Kudos

Brian, I definately appreciate your help in this matter. I definately am trying to help out other users as well either in the BSP thread or in the WAS Preview installation Thread. Just need to learn some more in order to become even more helpfull. For now, again many thanks in this matter and will ead through some XML documentation. Tiest

Answers (0)