on 06-24-2010 2:38 AM
Hi all,
I create a webservice consumer proxy to external server. the webservice provider is .Net and it required a message level security.
The soap message should include a soap header, like this:
<SOAP-ENV:Header>
<m:AuthHeader xmlns:m="http://tempuri.org/">
<m:Username>test1</m:Username>
<m:Password>test</m:Password>
</m:AuthHeader>
</SOAP-ENV:Header>
I have found many information from here. Now I used IF_WSPROTOCOL_WS_HEADER in my program, like this:
REPORT zws_jp_test01.
DATA: lo_zws_jp_co_service_soap TYPE REF TO zws_jp_co_service_soap .
DATA: lo_fault TYPE REF TO cx_ai_system_fault.
DATA: lo_appl_fault TYPE REF TO cx_ai_application_fault.
TRY.
CREATE OBJECT lo_zws_jp_co_service_soap
EXPORTING
logical_port_name = 'ZWS_JP_LP4'.
CATCH cx_ai_system_fault INTO lo_fault.
MESSAGE lo_fault TYPE 'I'.
ENDTRY.
DATA: output TYPE zws_jp_create_job_ad_soap_out .
DATA: input TYPE zws_jp_create_job_ad_soap_in .
DATA: lr_ws_header TYPE REF TO if_wsprotocol_ws_header.
DATA: lv_name TYPE string,
lv_namespace TYPE string.
DATA l_xstring TYPE xstring.
DATA l_string TYPE string.
DATA: ixml TYPE REF TO if_ixml,
xml_document TYPE REF TO if_ixml_document,
xml_root TYPE REF TO if_ixml_element,
xml_element TYPE REF TO if_ixml_element,
xml_node TYPE REF TO if_ixml_node.
lr_ws_header ?= lo_zws_jp_co_service_soap->get_protocol(
if_wsprotocol=>ws_header ).
CONCATENATE
'<SOAP-ENV:Header>'
'<m:AuthHeader xmlns:m="http://tempuri.org/">'
'<m:Username>test1</m:Username>'
'<m:Password>test</m:Password>'
'</m:AuthHeader>'
'</SOAP-ENV:Header>'
INTO l_string.
l_xstring = cl_proxy_service=>cstring2xstring( l_string ).
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = l_xstring
IMPORTING
document = xml_document
EXCEPTIONS
invalid_input = 1
OTHERS = 2.
IF sy-subrc = 0 AND NOT xml_document IS INITIAL.
xml_root = xml_document->get_root_element( ).
xml_element ?= xml_root->get_first_child( ).
WHILE NOT xml_element IS INITIAL.
lv_name = xml_element->get_name( ).
lv_namespace = xml_element->get_namespace_uri( ).
lr_ws_header->set_request_header(
name = lv_name
namespace = lv_namespace
dom = xml_element
must_understand = SPACE
).
xml_element ?= xml_element->get_next( ).
ENDWHILE.
ENDIF.
input-job_ad-id = 0.
input-job_ad_text-id = 0.
input-job_ad-publish_location = 1.
TRY.
CALL METHOD lo_zws_jp_co_service_soap->create_job_ad
EXPORTING
input = input
IMPORTING
output = output.
CATCH cx_ai_system_fault INTO lo_fault .
MESSAGE lo_fault TYPE 'I'.
CATCH cx_ai_application_fault INTO lo_appl_fault.
MESSAGE lo_appl_fault TYPE 'I'.
WRITE: output-create_job_ad_result-id.
ENDTRY.
But there is error when I run this program. the error is "SoapFaultCode:1"
In tcode ST11, I see this log:
E SOAP_RUNTIME 20100624004837.9280000 : CL_SOAP_RUNTIME_CLIENT
->EXEC_PROCESSING SOAP Fault Exception caught: : SOAP header To
was not understood.
btw the release is 701.
Any one can navigate me to solved the problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I have the same problem as you did before and I posted my code in this [thread|;.
In order to to solve your problem, I need to know what is the header that you want to add into the header, what is WSDL, and have you try testing that web service using other tool such as SOAPUI or XMLSPY and what is the result of testing tool?
Regards,
Chaiphon
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.