Alt 12.06.2011, 16:35:11   #1 (permalink)
ohne Vertrauen
Benutzerbild von Bububoomt

ID: 10361
Lose-Remote
Abwesend

Bububoomt eine Nachricht über ICQ schicken
Reg: 28.04.2006
Beiträge: 15.363
Bububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes Ansehen
Standard Curl Rückgabe auslesen

Ich habe folgende PHP Class, die ich gern in C# hätte

Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
class Adns { function call ($data) { $xml = new XML_Converter(); $data=to_utf8($data); $req = $xml->hash_to_xml( $data ); $res = $this->requestCurl( $req ); return $xml->xml_to_hash( $res ); } function requestCurl( $request ) { $ch = curl_init( HOST ); curl_setopt( $ch, CURLOPT_POSTFIELDS, $request ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, FALSE); if( !$response=curl_exec( $ch )) { echo " Curl execution error". curl_error( $ch ) ."\n".curl_errno($ch)."\n"; return FALSE; } curl_close( $ch ); # remove keep alive header while(substr($response, 0, 21) == "HTTP/1.1 100 Continue") { $response = substr($response, 25); } return $response; } }
Ich habe folgendes verwendet:
http://sourceforge.net/projects/libcurl-net/
http://blog.iarivas.com.ar/using-curl-with-c-net/

Mein Code:

Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
protected void Page_Load(object sender, EventArgs e) { sourceContent = new StringBuilder(); try { Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL); Easy easy = new Easy(); Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData); easy.SetOpt(CURLoption.CURLOPT_URL, @"DIEURL"); StringWriter strw = new StringWriter(); XmlTextWriter wr = new XmlTextWriter(strw); wr.WriteStartDocument(); wr.WriteStartElement("request"); //-->Authblock wr.WriteStartElement("auth"); wr.WriteElementString("user", "xxxx"); wr.WriteElementString("password", "xxxxxx"); wr.WriteElementString("context", "xxxx"); wr.WriteEndElement(); //<--Authblock //Mehr XMLDaten wr.WriteEndElement(); //<--task wr.WriteEndElement(); wr.WriteEndDocument(); easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS, strw.ToString()); easy.SetOpt(CURLoption.CURLOPT_POST, 1); easy.SetOpt(CURLoption.CURLOPT_READDATA, true); easy.SetOpt(CURLoption.CURLOPT_WRITEDATA, true); easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, false); easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYHOST, false); easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf); easy.Perform(); easy.Cleanup(); Curl.GlobalCleanup(); } catch (Exception ex) { } ausgabe.InnerHtml = sourceContent.ToString(); } public Int32 OnWriteData(Byte[] buf, Int32 size, Int32 nmemb, Object extraData) { this.sourceContent.Append(System.Text.Encoding.UTF8.GetString(buf)); return size * nmemb; }
Leider erhalte ich keine Rückgabe auch lande ich gar nicht in der OnWriteData beim Debuggen.

Jemand eine Idee??
.DE 1. Jahr 3,95€, 2.Jahr oder Tranfer nur 2,95€! +2 Backlinks je Domain! ab 20 Domains+3 BL/Domain, ab 50 Domains+4BL/Domain!
Angebot mit Backlink (Preise sind dauerhaft gültig!) bis 31.5.2012!! Weitere Preise auf Anfrage
-> PN an Mich
Screenshot machen MammutHaNull Gold verkaufen
Bububoomt ist offline   Mit Zitat antworten
Alt 12.06.2011, 20:27:36   #2 (permalink)
ohne Vertrauen
Benutzerbild von Bububoomt

ID: 10361
Lose-Remote
Abwesend

Bububoomt eine Nachricht über ICQ schicken
Reg: 28.04.2006
Beiträge: 15.363
Bububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes AnsehenBububoomt genießt hohes Ansehen
Standard

Jetzt habe ich mal folgendes versucht:

Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("https://URL/"); //Defined poperties for the Web-Request httpWebRequest.Method = "POST"; httpWebRequest.MediaType = "HTTP/1.1"; httpWebRequest.ContentType = "text/xml"; httpWebRequest.UserAgent = "Example Client"; //Defined data for the Web-Request byte[] byteArrayData = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"utf-8\"?><request><auth><user>xxxx</user><password>xxxx</password><context>XXX</context></auth></request>"); httpWebRequest.ContentLength = byteArrayData.Length; //Attach data to the Web-Request Stream dataStream = httpWebRequest.GetRequestStream(); dataStream.Write(byteArrayData, 0, byteArrayData.Length); dataStream.Close(); //Send Web-Request and receive a Web-Response HttpWebResponse httpWebesponse = (HttpWebResponse)httpWebRequest.GetResponse(); //Translate data from the Web-Response to a string dataStream = httpWebesponse.GetResponseStream(); StreamReader streamreader = new StreamReader(dataStream, Encoding.UTF8); string response = streamreader.ReadToEnd(); streamreader.Close();
Damit bekomme ich nun auch eine Rückgabe leider aber folgendes:
Code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
<?xml version="1.0" encoding="utf-8" ?> <response> <result> <msg> <code>EF00000</code> <help></help> <object> <type>XML error</type> <value>xmlParseStartTag: invalid element nameexpected '&gt;'Opening and ending tag mismatch: key line 1 and unparseablexmlParseStartTag: invalid element nameexpected '&gt;'Opening and ending tag mismatch: task line 1 and unparseablexmlParseStartTag: invalid element nameexpected '&gt;'Opening and ending tag mismatch: request line 1 and unparseableExtra content at the end of the document at /usr/lib/perl5/XML/LibXML/SAX.pm line 64 at /usr/share/perl5/XML/Simple.pm line 295</value> </object> <text>Fehler beim Lesen des Auftrages.</text> <type>error</type> </msg> <status> <code>E00000</code> <text>Es sind Fehler bei der Verarbeitung aufgetreten.</text> <type>error</type> </status> </result> </response> <?xml version="1.0" encoding="utf-8" ?> <response> <result> <msg> <code>EF00000</code> <help></help> <object> <type>XML error</type> <value>xmlParseStartTag: invalid element nameexpected '&gt;'Opening and ending tag mismatch: key line 1 and unparseablexmlParseStartTag: invalid element nameexpected '&gt;'Opening and ending tag mismatch: task line 1 and unparseablexmlParseStartTag: invalid element nameexpected '&gt;'Opening and ending tag mismatch: request line 1 and unparseableExtra content at the end of the document at /usr/lib/perl5/XML/LibXML/SAX.pm line 64 at /usr/share/perl5/XML/Simple.pm line 295</value> </object> <text>Fehler beim Lesen des Auftrages.</text> <type>error</type> </msg> <status> <code>E00000</code> <text>Es sind Fehler bei der Verarbeitung aufgetreten.</text> <type>error</type> </status> </result> </response>
jemand eine Idee?
.DE 1. Jahr 3,95€, 2.Jahr oder Tranfer nur 2,95€! +2 Backlinks je Domain! ab 20 Domains+3 BL/Domain, ab 50 Domains+4BL/Domain!
Angebot mit Backlink (Preise sind dauerhaft gültig!) bis 31.5.2012!! Weitere Preise auf Anfrage
-> PN an Mich
Screenshot machen MammutHaNull Gold verkaufen
Bububoomt ist offline Threadstarter   Mit Zitat antworten
Antwort

Gesponsorte Links

Anzeige


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 
Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an


Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
curl in php.ini erlauben Tab Webhosting 3 18.04.2010 11:59:32
Rückgabe teurer Geräte Muebarekking Das wahre Leben 23 27.08.2007 13:49:39
Douglas: Rückgabe als Gutschein Brownie Gott und die Welt 10 07.05.2007 15:07:24
[Javascript] Rückgabe an Datei ChristianK Programmierung 1 03.03.2007 11:38:14


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:10:27 Uhr.