1

複数の 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>
4

2 に答える 2

4

groovy wsliteを使用して、同じこと (ただし機能すること) をはるかに少ないコードで行うことができます。

@Grab( 'com.github.groovy-wslite:groovy-wslite:0.8.0' )
import wslite.soap.*
import wslite.http.auth.*

def client = new SOAPClient( 'https://test.anis.ch/HTDB.WebService/AnimalImportService.asmx' )

client.authorization = new HTTPBasicAuthorization( "613731", "test" )

// Trust the ssl for this site
client.httpClient.sslTrustAllCerts = true

def response = client.send(SOAPAction:'urn:tvd:heimtierdatenbanksql:webservice:animalimportservcie:v1:getAnimalsIn') {
    body {
        getAnimals( 'xmlns':'urn:tvd:heimtierdatenbanksql:webservice:animalimportmessages:v1' ) {
            getMessage {
                Header( 'xmlns':'urn:tvd:heimtierdatenbanksql:webservice:animalimportdata:v1' ) {
                    P_Praxisnummer( '371066' )
                    P_Account( '613731' )
                    P_PIN( 'test' )
                }
                Body( 'xmlns':'urn:tvd:heimtierdatenbanksql:webservice:animalimportdata:v1' ) {
                    KZ_Kennzeichnung( '756000100230345' )
                }
            }
        }
    }
}

println XmlUtil.serialize( response.getAnimalResponse )

あなたのために働く指が交差しました!

私は得る:

<tag0:getAnimalResponse xmlns:tag0="urn:tvd:heimtierdatenbanksql:webservice:animalimportmessages:v1">
  <tag0:outputMessage>
    <R_Fehlertext xmlns="urn:tvd:heimtierdatenbanksql:webservice:animalimportdata:v1">Account-Informationen nicht plausibel</R_Fehlertext>
    <R_FehlerCode xmlns="urn:tvd:heimtierdatenbanksql:webservice:animalimportdata:v1">109</R_FehlerCode>
  </tag0:outputMessage>
</tag0:getAnimalResponse>

だから、私の資格情報に何か問題があると思います...

于 2013-11-13T09:28:32.643 に答える