develop:xmlrpc:init
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende ÜberarbeitungLetzte ÜberarbeitungBeide Seiten der Revision | ||
develop:xmlrpc:init [d.m.Y H:i] – willuhn | develop:xmlrpc:init [d.m.Y H:i] – [PHP] willuhn | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== XML-RPC Verbindungsaufbau ====== | ||
- | Beispiel-Code für den Verbindungsaufbau via XML-RPC | ||
- | |||
- | ===== Java ===== | ||
- | |||
- | Sie benötigen hierzu das Modul [[http:// | ||
- | |||
- | <code java> | ||
- | import java.net.URL; | ||
- | import java.security.SecureRandom; | ||
- | import java.security.cert.X509Certificate; | ||
- | |||
- | import javax.net.ssl.HostnameVerifier; | ||
- | import javax.net.ssl.HttpsURLConnection; | ||
- | import javax.net.ssl.SSLContext; | ||
- | import javax.net.ssl.SSLSession; | ||
- | import javax.net.ssl.TrustManager; | ||
- | import javax.net.ssl.X509TrustManager; | ||
- | |||
- | import org.apache.xmlrpc.client.XmlRpcClient; | ||
- | import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; | ||
- | |||
- | |||
- | public class Test | ||
- | { | ||
- | public static void main(String[] args) throws Exception | ||
- | { | ||
- | String url = " | ||
- | |||
- | // Client-Config erzeugen | ||
- | XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); | ||
- | config.setBasicPassword(< | ||
- | config.setBasicUserName(" | ||
- | config.setServerURL(new URL(url)); | ||
- | |||
- | if (url.startsWith(" | ||
- | disableCertCheck(); | ||
- | | ||
- | XmlRpcClient client = new XmlRpcClient(); | ||
- | client.setConfig(config); | ||
- | |||
- | Object result = client.execute("< | ||
- | } | ||
- | |||
- | /** | ||
- | * Falls HTTPS aktiviert ist, muessen Sie entweder Java das Jameica-Zertifikat | ||
- | * (Datei-> | ||
- | * bei SUN Java mitgelieferten Programm [[http:// | ||
- | * importieren oder (NUR ZU TESTZWECKEN!) die Zertifikats-Prüfung abschalten. | ||
- | * Die folgende Funktion tut dies. | ||
- | * @throws Exception | ||
- | */ | ||
- | private static void disableCertCheck() throws Exception | ||
- | { | ||
- | TrustManager dummy = new X509TrustManager() | ||
- | { | ||
- | public java.security.cert.X509Certificate[] getAcceptedIssuers(){return null;} | ||
- | public void checkClientTrusted (X509Certificate[] certs, String authType) {} | ||
- | public void checkServerTrusted(X509Certificate[] certs, String authType) {} | ||
- | }; | ||
- | | ||
- | SSLContext sc = SSLContext.getInstance(" | ||
- | sc.init(null, | ||
- | HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); | ||
- | HostnameVerifier dummy2 = new HostnameVerifier() { | ||
- | public boolean verify(String host, SSLSession session) {return true;} | ||
- | }; | ||
- | HttpsURLConnection.setDefaultHostnameVerifier(dummy2); | ||
- | } | ||
- | } | ||
- | </ | ||
- | |||
- | |||
- | |||
- | ===== Perl ===== | ||
- | |||
- | Sie benötigen hierzu das CPAN-Modul [[http:// | ||
- | |||
- | <code perl> | ||
- | # | ||
- | |||
- | use strict; | ||
- | use RPC::XML; | ||
- | use RPC:: | ||
- | |||
- | my $cli = RPC:: | ||
- | $cli-> | ||
- | |||
- | my $resp = $cli-> | ||
- | </ | ||
- | |||
- | ===== PHP ===== | ||
- | |||
- | Sie benötigen hierzu das PHP-Modul [[http:// | ||
- | |||
- | <code php> | ||
- | include(" | ||
- | $client = new xmlrpc_client(" | ||
- | $client-> | ||
- | |||
- | // Wenn im folgenden Parameter " | ||
- | // Jameica exportieren (Datei-> | ||
- | // " | ||
- | // an "/ | ||
- | // HTTP-Kommunikation verwendet) | ||
- | // Verwenden Sie " | ||
- | $client-> | ||
- | |||
- | // Aktiviert/ | ||
- | $client-> | ||
- | |||
- | $msg = new xmlrpcmsg("< | ||
- | $response = $client-> | ||
- | |||
- | // Ergebnis auswerten, z.Bsp.: | ||
- | print($response-> | ||
- | |||
- | // Alternativ Fehlermeldung ausgeben | ||
- | print($response-> | ||
- | </ |
Impressum | Datenschutz
develop/xmlrpc/init.txt · Zuletzt geändert: d.m.Y H:i von willuhn