You are not logged in.

  • Login

1

Thursday, November 16th 2006, 10:53am

C# to PHP

Hi zusammen,

Ich konnte mich nicht entscheiden ob dies nun ins C# oder ins PHP gehört :) Wenns falsch ist, einfach verschieben.

Okay, ich bräuchte folgenden C# Code in PHP übersetzt, den PHP Code selbst zu bilden ist mir ums verrecken nicht gelungen :(

Hier der C# Code:

C Quellcode

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
using System;
using SendTextMessage.anbieter.Webservices; // import the fax web service proxy
namespace SendTextMessage
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
Console.WriteLine ("Sending text message using Send operation …");
// Creating data to send Fax
Outbound faxData = new Outbound();
faxData.CustomerID = "<your customer ID>"; // field required
faxData.Password = "<your password>"; // field required
faxData.Subject = "Testing Send operation";
faxData.Body = "Sending text message using Send operation ...";
faxData.BodyContentType ="text/plain";
// Add one Recipient
faxData.Recipients = new OutboundRecipient[1];
faxData.Recipients[0] = new OutboundRecipient();
faxData.Recipients[0].Phone = "<recipient number>"; // field required
faxData.Recipients[0].Name = "<recipient name>";
faxData.Recipients[0].TransactionID = Guid.NewGuid().ToString();
try
{
FaxService serviceProxy = new FaxService();
//second parameter is null to avoid advanced features.
string[] transactionIDs = serviceProxy.Send(faxData, null);
foreach(string transactionID in transactionIDs)
{
Console.WriteLine ("Fax sent. Id: {0}", transactionID);
}
}
catch (Exception e)
{
Console.WriteLine ("Error {0}", e);
}
}
}
}


Und hier mein PHP dazu:

PHP Quellcode

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
<?php
 
$client = new SoapClient( "http://webservices.anbieter.net/fax/1.0/faxservice.asmx?WSDL", array("trace" => 1, "exceptions" => 0));
 
$odocdet = array
(
"TransferEncoding" 		=> "base64",
"FileData"				=> "base64",
"ContentType"			=> "text/plain",
);
 
 
$odetails = array
(
"TransactionID"			=> '',
"Name" 					=> "Receipt Name",
"Phone"					=> "49899543988xx",
);
 
$params = array
(
"customerID" 			=> "490005xxx",
"Password"   			=> "xxxxxxx",
"ConfirmationURL" 		=> "mailto:matthias@anbieter.com",
"CSID" 					=> "CSID FIELD",
"Sender"				=> "Sender Field",
"Sendername"			=> "Sender Name",
"Header"				=> "Header Field",
"Subject"				=> "Subject Field",
"Body"					=> "Body part",
"BodyContentType"		=> "text/plain",
"Resolution"			=> "1",
"TestMode"				=> "true",
"Recipients"			=> $odetails,
"Documents"				=> $odocdet,
"Date"					=> "1999-01-0108:08:08+01:00",
"Retries"				=> "2"
);
 
$res = $client->Send($params); 
print_r($res); 
?>


Ich wäre wirklich sehr sehr dankbar für Hilfe. Ich gebe nicht auf bevor das läuft :) Nur weiß ich mir momentan nicht anders zu helfen als zu fragen.

Ahjaa, hier noch die derzeitige Rückmeldung vom Webserver der den SOAP Request annimmt:

[faultstring] => Server was unable to process request. --> Object reference not set to an instance of an object. [faultcode] => soap:Server [detail] => )

Merci schon mal vorab,

Matthias

2

Thursday, November 16th 2006, 11:16am

Ich hab dir doch eh schon eine Vorlage im XML-Thread gepastet.
Kannst du zumindest die Felder selber einfügen - danke

3

Thursday, November 16th 2006, 11:53am

Hi!

Danke, du warst einfach zu schnell für mich :) Merci. Ich schau mir deine Antwort an und nerv in dem Thread weiter :)

Matze

Social bookmarks