You are not logged in.

  • Login

1

Wednesday, December 2nd 2009, 12:49pm

xml file an server posten

Hi zusammen,

Ich möchte gerne mit einem entfernten Server kommunizieren, hierfür möchte ich PHP5 nutzen. Laut dessen Anleitung benötigt er die übergebenen Daten folgendermaßen:

"Fax messages shall be submitted using an http form post (content-type text/xml) to http://provider.net/xml2fax/1.1/send.asp. The https post shall contain a XML
document conforming to the DTD specified below. Each upload request consists of a single
XML file"

Dann gibt es noch eine DTD

Quoted

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT outbound (recipient+, document+)>
<!ATTLIST outbound
customer-id CDATA #REQUIRED
auth-method (plain | basic | digest) #REQUIRED
auth-string CDATA #REQUIRED
confirmation-url CDATA ""
csid CDATA ""
user-id CDATA ""
header CDATA ""
subject CDATA ""
date CDATA ""
retries CDATA ""
user-id-name CDATA ""
resolution CDATA "">
<!ELEMENT recipient EMPTY>
<!ATTLIST recipient
transaction-id CDATA "0"
name CDATA ""
company CDATA ""
destination CDATA #REQUIRED>
<!ELEMENT document (#PCDATA)>
<!ATTLIST document
content-type CDATA "text/html"
content-transfer-encoding CDATA "base64">


und natürlich ein Beispiel XML

XML Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE outbound
SYSTEM "http://provider.net/xml2fax/1.1/outbound.dtd">
<outbound
customer-id="999999999"
auth-method="basic"
auth-string="ueDhrvGt1rfq1q9qvvutwpauepmifn"
user-id=”Marketing Dept.”
header=”ACME INC.”
confirmation-url="mailto://temp@tempuri.org">
<recipient
transaction-id="b31b8793-abaf-11d5-c450-c7fcf46a01f5"
name="John Doe"
company="Doe-A-Deer, Inc"
destination=”15551239876/>
<document
content-type="text/html"
content-transfer-encoding="base64">
gyutmtizndvyqfbktcbtrvqguefhrvbst1rfq1q9qvvutwpauepmifnfv....
</document>
</outbound>


Ich habe es mit curl versucht, auch mit normalem post formular, und selbst mit simpleXML habe ich mich geplagt, aber irgendwie hakt es, kann mir jemand weiterhelfen?

Merci vorab,
Grüße,
Matthias

2

Wednesday, December 2nd 2009, 9:22pm

Hi
Von SimpleXML würde ich erstmal absehen und das ganze stattdessen direkt als String bzw Datei senden.

Beispiel:

PHP Quellcode

1
2
3
4
5
6
7
8
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "http://www.example.com"); 
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); 
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('dein xml dokument')); 
$antwort= curl_exec($ch);
curl_close ($ch);

3

Thursday, December 3rd 2009, 10:16am

Moin zusammen,

Danke für die Hilfe d0nut - aber ich bekomme auch mit deinem Code die alte Antwort "access denied" - das liegt aber nicht an falschen Zugangsdaten sondern daran das er mit meinen übergebenen Daten ein Problem hat, er kann Sie nicht lesen.
Ich weiß nicht wirklich weiter, nicht mal wie ich um Hilfe fragen soll.

Hier nochmal mein derzeitiger Code:

Hier mein XML File welches ich dem CURL mitgebe:

XML Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE outbound
SYSTEM "http://webservices.provider.net/xml2fax/1.1/outbound.dtd">
<outbound
customer-id="999999999"
auth-method="basic"
auth-string="ueDhrvGt1rfq1q9qvvutwpauepmifn"
user-id=”Marketing Dept.”
header=”ACME INC.”
confirmation-url="mailto://temp@tempuri.org">
<recipient
transaction-id="b31b8793-abaf-11d5-c450-c7fcf46a01f5"
name="John Doe"
company="Doe-A-Deer, Inc"
destination=”15551239876/>
<document
content-type="text/html"
content-transfer-encoding="base64">
gyutmtizndvyqfbktcbtrvqguefhrvbst1rfq1q9qvvutwpauepmifnfv....
</document>
</outbound>


Und hier das PHP Script welches ich im Browser öffne:

PHP Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
<?
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "http://webservices.provider.net/xml2fax/1.1/send.asp"); 
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); 
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('request.xml'));
$antwort= curl_exec($ch);
curl_close ($ch);
var_dump($antwort);
var_dump(file_get_contents('request.xml'));
?>


Die Antwort des Servers lautet immer:

string(19) "Access is denied. " string(624) " gyutmtizndvyqfbktcbtrvqguefhrvbst1rfq1q9qvvutwpauepmifnfv.... "

Für mich sieht es so aus als wäre das XML das ich ihm gebe nicht valide ... sollte es aber sein, denn es ist das original aus der Anleitung des Herstellers der den XML Server vorhält. Ich checks wahrscheinlich einfach mal nur nicht, weiß noch jemand weiter?

Grüße,
Matze

4

Thursday, December 3rd 2009, 6:46pm

zumindest sehen die Windows Anführungszeichen bei user-id und header, wie du sie hier sehr schön grün hervorgehoben bekommst, sehr nach einem falschen Zeichensatz aus.

Ich würde einfach mal beim Webservice Provider anfragen.
Die können das über ihre Logfiles bestimmt einfach herausfinden.
Und auch werden sie schon öfter in Kontakt mit PHP Clients gekommen sein.

Lg

5

Thursday, December 3rd 2009, 8:00pm

Hi!

Danke für deine Antwort, aber von deren Seite ist soviel Hilfe zu erwarten wie bei ner Kuh vom Weitsprung, naja, dann muss ich weiterforschen, ich muss dass zwingend hinkriegen :(

Similar threads

Social bookmarks