BookmarkSubscribeRSS Feed
jeffstc
Calcite | Level 5

I seem to be having an issue with encoding when invoking proc http.

 

Here is the code I am using to invoke an WSDL web serivce

 

filename request temp;
filename response temp;
filename header temp; data _NULL_; file header; put 'SOAPAction: "http://tempuri.org/IGCodeService/TextsMatch"'; run; proc http url="http://gcodeservice-prod/service.svc" method="POST" headerin=header CT="text/xml; charset=utf-8" in=request out=response; quit;

Before running the above code I have a data step that produces the following content for the request file...

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header/>
    <s:Body>
        <TextsMatch xmlns="http://tempuri.org/">
            <CodingDatabaseReferences xmlns:d4p1="http://schemas.datacontract.org/2004/07/GCodeService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <d4p1:CodingDatabaseReference>
                    <d4p1:CodingDatabaseIdentifier>4cdcff3c-a7cc-4ac1-b4d4-8151ec39bc55</d4p1:CodingDatabaseIdentifier>
                    <d4p1:FilterUsage>NoFilter</d4p1:FilterUsage>
                </d4p1:CodingDatabaseReference>
                <d4p1:CodingDatabaseReference>
                    <d4p1:CodingDatabaseIdentifier>08c7247f-cde8-4f6d-8078-1a571f4a9117</d4p1:CodingDatabaseIdentifier>
                    <d4p1:FilterUsage>NoFilter</d4p1:FilterUsage>
                </d4p1:CodingDatabaseReference>
                <d4p1:CodingDatabaseReference>
                    <d4p1:CodingDatabaseIdentifier>a5894c8c-d051-4b98-96eb-b2ac2f0457d6</d4p1:CodingDatabaseIdentifier>
                    <d4p1:FilterUsage>NoFilter</d4p1:FilterUsage>
                </d4p1:CodingDatabaseReference>
                <d4p1:CodingDatabaseReference>
                    <d4p1:CodingDatabaseIdentifier>cbd141e3-248d-4209-a4f3-a2c5c4b37e4b</d4p1:CodingDatabaseIdentifier>
                    <d4p1:FilterUsage>NoFilter</d4p1:FilterUsage>
                </d4p1:CodingDatabaseReference>
                <d4p1:CodingDatabaseReference>
                    <d4p1:CodingDatabaseIdentifier>f52dd135-6f04-4a19-aa08-139fe2d2e614</d4p1:CodingDatabaseIdentifier>
                    <d4p1:FilterUsage>NoFilter</d4p1:FilterUsage>
                </d4p1:CodingDatabaseReference>
                <d4p1:CodingDatabaseReference>
                    <d4p1:CodingDatabaseIdentifier>65895ba3-ac4b-4135-b597-a0c97aff3851</d4p1:CodingDatabaseIdentifier>
                    <d4p1:FilterUsage>NoFilter</d4p1:FilterUsage>
                </d4p1:CodingDatabaseReference>
                <d4p1:CodingDatabaseReference>
                    <d4p1:CodingDatabaseIdentifier>c506d462-6ebc-48df-b484-fb22f85c2279</d4p1:CodingDatabaseIdentifier>
                    <d4p1:FilterUsage>NoFilter</d4p1:FilterUsage>
                </d4p1:CodingDatabaseReference>
                <d4p1:CodingDatabaseReference>
                    <d4p1:CodingDatabaseIdentifier>9249b1fa-e196-4ca0-9644-e19760b450b1</d4p1:CodingDatabaseIdentifier>
                    <d4p1:FilterUsage>NoFilter</d4p1:FilterUsage>
                </d4p1:CodingDatabaseReference>
            </CodingDatabaseReferences>
            <TextsToMatch xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <d4p1:string>ELECTRONIC PRECISION EQUIPMENT R M ³NAICS-811210U</d4p1:string>
            </TextsToMatch>
            <MatchParams xmlns:d4p1="http://schemas.datacontract.org/2004/07/GCodeService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <d4p1:Delta>0</d4p1:Delta>
                <d4p1:ListSort>Code</d4p1:ListSort>
                <d4p1:ListType>AllCode</d4p1:ListType>
                <d4p1:MatchAlgorighm>Direct</d4p1:MatchAlgorighm>
                <d4p1:MaxList>5</d4p1:MaxList>
                <d4p1:Possible>0</d4p1:Possible>
                <d4p1:ScoreMethod>WORD</d4p1:ScoreMethod>
                <d4p1:Winner>10</d4p1:Winner>
            </MatchParams>
            <StopWhenWinnerFound>true</StopWhenWinnerFound>
        </TextsMatch>
    </s:Body>
</s:Envelope>

**notice the strange character in the <d4p1:string> tag

 

Running the above will fail with a response of 500 from the web service, however if I ensure the request file is encoded to utf-8 (I manually change it by opening it in Notepad++ and converting it) I can get it to run without error but the response contains improper characters.  Below is the response content found in the response file..part of the content returned indicates the text string that was sent to the web service.

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<TextsMatchResponse xmlns="http://tempuri.org/">
<TextsMatchResult xmlns:a="http://schemas.datacontract.org/2004/07/GCodeService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:CDMatchResultSet>
<a:FilterToMatch i:nil="true"/>
<a:Items/>
<a:ResultMatchAlgorithm>NotApplicable</a:ResultMatchAlgorithm>
<a:ResultType>Fail</a:ResultType>
<a:TextToMatch>ELECTRONIC PRECISION EQUIPMENT R M ³NAICS-811210U</a:TextToMatch>
<a:Timespan>PT0S</a:Timespan>
</a:CDMatchResultSet>
</TextsMatchResult>
</TextsMatchResponse>
</s:Body>
</s:Envelope>

Notice the additional character (Â) that was added to the text string in the <a:TextToMatch>.  Note this is not something the web service is adding or any issue of the web service as it works completely fine in other environments.

 

I have tried to ensure the encoding of all three temp files were utf-8 during file reference statements but all hell breaks out and my SAS program fails completely.  The only file that I can specify the encoding='utf-8' for is the response file...any other files cause issues.

 

I believe this is some sort of encoding/character translation issue but I have no idea what to do next to try and resolve this.

 
1 REPLY 1
ballardw
Super User

Look to your data step building  Request and the contents of any input data set used in that step. The input data likely has the coding issue and may trace back to how the file was read.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1543 views
  • 0 likes
  • 2 in conversation