複数の SOAP メッセージを試してみました。それらをソリューションに貼り付けようとしましたが、答えを得る方法がありません。
この Groovy コードを使用して、SOAP 要求を送信し、SOAP 応答を取得します。また、2 つの Web サービスで動作します。私は SoapUI を使用して XML を記述しました。ここで使用する XML は SoapUI で動作し、サーバーから回答を取得します。
現在、作業中の XML と作業中の Groovy スクリプト (他のサービス用) が連携して動作せず、問題の原因がわかりません。私は開発者ではありません。SSL エラーが発生しましたが、このサーバーには SSL 証明書がないと確信しており、SSL なしの SoapUI では機能しており、プロバイダーから必要な証明書がないと言われました。
どこに問題があるのか教えてください。よろしくお願いします。
敬具。アントワーヌ
Groovy スクリプト:
// Send data
URL url = new URL(url);
HttpURLConnection conn = url.openConnection();
conn.setDoOutput(true);
if( soapaction != null ) conn.setRequestProperty( "SOAPAction", soapaction );
conn.setRequestProperty( "Content-Type", "text/xml" );
String authorizationString = "Basic " + (username + ":" + password).bytes.encodeBase64();
conn.setRequestProperty ("Authorization", authorizationString);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(xml);
wr.close();
// Get the response
String response;
InputStream responseStream;
try {
responseStream = conn.getInputStream();
success = 1;
} catch( IOException e ) {
success = 0;
if( conn.getResponseCode() == 500 ) {
responseStream = conn.getErrorStream();
} else throw e;
}
response = responseStream.getText("utf-8");
responseStream.close();
return response;
このスクリプトのパラメーター:
XML
soapaction : getAnimals
URL : https://test.anis.ch/HTDB.WebService/AnimalImportService.asmx
パスワード : テスト
ユーザー名 : 613731
XML:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlso.../soap/envelope/" xmlns:urn="urn:tvd:heimtierdatenbanksql:webservice:animalimportmessages:v1" xmlns:urn1="urn:tvd:heimtierdatenbanksql:webservice:animalimportdata:v1">
<soapenv:Header/>
<soapenv:Body>
<urn:getAnimals>
<urn:getMessage>
<urn1:Header>
<urn1:P_Praxisnummer>371066</urn1:P_Praxisnummer>
<urn1:P_Account>613731</urn1:P_Account>
<urn1:P_PIN>test</urn1:P_PIN>
</urn1:Header>
<urn1:Body>
<!--1 or more repetitions:-->
<urn1:KZ_Kennzeichnung>756000100230345</urn1:KZ_Kennzeichnung>
</urn1:Body>
</urn:getMessage>
</urn:getAnimals>
</soapenv:Body>
</soapenv:Envelope>