BookmarkSubscribeRSS Feed
zinabenammar
Fluorite | Level 6

I have a problem to invoke the web service shared by SAS using DS2.

Please note that proc soap working fine for me.

proc ds2;

data _null_;
method run();
/* instantiate the package */
declare package http h();
declare varchar(1024) body ;
declare int rc;

DECLARE varchar(10000) content;

content=
'<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soap="http://www.SoapClient.com/xml/SoapResponder.xsd">
<soapenv:Header/>
<soapenv:Body>
<soap:Method1 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<bstrParam1 xsi:type="xsd:string">apple</bstrParam1>
<bstrParam2 xsi:type="xsd:string">zebra3</bstrParam2>
</soap:Method1>
</soapenv:Body>
</soapenv:Envelope>
;;;;' ;

/* create a GET */
h.createPostMethod('http://soapclient.com/xml/soapresponder.wsdl');
h.setRequestBodyAsString(content);

h.setRequestContentType('text/xml; charset="utf-8"');
/* execute the GET */
h.executeMethod();
/* retrieve the response body as a string */

h.getResponseBodyAsString(body, rc);
put body;
end;

run;

 

 

Log:

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73
74 proc ds2;
75
76 data _null_;
77 method run();
78 /* instantiate the package */
79 declare package http h();
80 declare varchar(1024) body ;
81 declare int rc;
82
83 DECLARE varchar(10000) content;
84
85 content=
86 '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
90 <soapenv:Header/>
NOTE: The quoted string currently being processed has become more than 262 bytes long. You might have unbalanced quotation marks.
91 <soapenv:Body>
92 <soap:Method1
93 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
94 <bstrParam1 xsi:type="xsd:string">apple</bstrParam1>
95 <bstrParam2 xsi:type="xsd:string">zebra3</bstrParam2>
96 </soap:Method1>
97 </soapenv:Body>
98 </soapenv:Envelope>
99 ;;;;' ;
100
101 /* create a GET */
103 h.setRequestBodyAsString(content);
104
105 h.setRequestContentType('text/xml; charset="utf-8"');
106 /* execute the GET */
107 h.executeMethod();
108 /* retrieve the response body as a string */
109
110 h.getResponseBodyAsString(body, rc);
111 put body;
112 end;
113
114 run;
<?xml version="1.0"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body>
<SOAP-ENV:Fault> <faultcode>SOAP-ENV:Client</faultcode> <faultstring>Error Parsing Request
Message.</faultstring> <faultactor>/xml/soapresponder.wsdl</faultactor> <detail>
<e:faultdetails xmlns:e="http://sqldata.com/soapfault"> <message>Error at Line 1, position 562 Error c00cee2d,
Incorrect document syntax.</message> <errorcode>1526</errorcode> </e:faultdetails> </detail>
</SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
NOTE: Note from DS2 package d2http:
NOTE: Failed to determine character set from request content type. Defaulting to UTF-8 for encoding the request body.
ERROR: Error reported by DS2 package d2http:
ERROR: Invalid character set '"utf-8"'.
NOTE: Note from DS2 package d2http:
NOTE: Failed to determine character set from response content type (text/xml; charset="utf-8"). Defaulting to UTF-8 for decoding
the response body.
NOTE: Execution succeeded. No rows affected.
115
116 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
128

 

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Stabs in the dark. Instead of

h.setRequestContentType('text/xml; charset="utf-8"');

try

h.setRequestContentType('text/xml; charset=utf-8');

or

h.setRequestContentType('application/soap+xml; charset=utf-8');

 

 

 

 

 

 

 

zinabenammar
Fluorite | Level 6

Thank's for your response.

 

I tried both of but i'm still having the same error :

 
NOTE: Failed to determine character set from request content type. Defaulting to UTF-8 for encoding the request body.
ERROR: Error reported by DS2 package d2http:
ERROR: Invalid character set '"utf-8"'.
NOTE: Note from DS2 package d2http:
NOTE: Failed to determine character set from response content type (text/xml; charset="utf-8"). Defaulting to UTF-8 for decoding
the response body.
NOTE: Execution succeeded. No rows affected.
ChrisNZ
Tourmaline | Level 20

It's strange that the error message quotes the string  utf-8  if you did not. No more idea, sorry.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 916 views
  • 0 likes
  • 2 in conversation