Autor Beitrag
DerNetteNachbar
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 224



BeitragVerfasst: Di 13.10.09 14:21 
Hey Leute,
ich versuche momentan ein Client zu schreiben der sich mit einem WebService verbindet und eine XML Struktur wie diese hier:
ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
<?xml version="1.0"?>
<articleCatalogueRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://salesweb.phoenix-ag.de/wsxmlgermany/schemas/PhoenixArticleCatalogueRequestDE.xsd">  
<client branchNumber="51" customerNumber="53143"/>
  <articles insertMasterData="yes">
    <byArticleNumber articleNumber="2495052" requestedQuantity="200"/>
    <byArticleNumber articleNumber="7621113" requestedQuantity="300"/>
    <byArticleNumber articleNumber="831669" requestedQuantity="300"/>
    <byArticleNumber articleNumber="78597"/>
    <byArticleNumber articleNumber="3524436"/>
    <byArticleNumber articleNumber="3648629"/>

    <byEAN EAN="4103380854860"/>
  </articles>
  <browseRequest requestKey="no"/>
</articleCatalogueRequest>


in einem HTTP Body überträgt.

Hab es schon mit IdHTTP versucht leider liefert mir der Server: Request enthält keine gültigen XML Daten zurück.

Mein Delphi Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  IdHTTP := TIdHTTP.Create(nil);
  IdHTTP.Request.BasicAuthentication := True;
  IdHTTP.Request.Username := strUsername;
  IdHTTP.Request.Password := strPassword;
  IdHTTP.IOHandler := IdSSLIOHandlerSocket1;

  strXMLResponse := IdHTTP.Post(strURL2Interface, s);
  strXMLResponse := IdHTTP.Get(strURL2Interface);


Equivalnet dazu gibt es einen C# Code dieser auch klappt:

ausblenden volle Höhe C#-Quelltext
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:
57:
58:
59:
60:
61:
62:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;

namespace PHOENIX
{
    class Program
    {
        static string useSalesWeb(String URL, String User, String Password, String XMLRequest)
        {
            String retval = String.Empty;

            try
            {
                WebRequest wreq = WebRequest.Create(URL);
                wreq.Method = "POST";
                wreq.Credentials = new NetworkCredential(User, Password);

                byte[] data = Encoding.ASCII.GetBytes(XMLRequest);
                Stream s = wreq.GetRequestStream();
                s.Write(data, 0, data.Length);
                s.Close();

                WebResponse wres = wreq.GetResponse();
                StreamReader sr = new StreamReader(wres.GetResponseStream());

                retval = sr.ReadToEnd();
            }
            catch (Exception ex)
            {
                retval = ex.Message;
            }

            return retval;
        }

        static void Main(string[] args)
        {            
       
            String strURL2Interface = "https://salesweb.phoenix-ag.de/wsxmlgermany/articlecatalogue.php";
            String strUsername = "";
            String strPassword = "";
            String strXMLRequest = "";
            String strXMLResponse = "";

            strXMLRequest =  "<articleCatalogueRequest>";
            strXMLRequest += "<client branchNumber=\"05\" customerNumber=\"9999005\" />";
            strXMLRequest += "<articles insertMasterData=\"yes\">";
            strXMLRequest += "<byArticleNumber articleNumber=\"2181193\" requestedQuantity=\"1\" />";
            strXMLRequest += "<byArticleNumber articleNumber=\"5438362\" requestedQuantity=\"1\" />";
            strXMLRequest += "</articles>";
            strXMLRequest += "</articleCatalogueRequest>";

            strXMLResponse = useSalesWeb(strURL2Interface, strUsername, strPassword, strXMLRequest);

            Console.WriteLine(strXMLResponse);
            Console.ReadLine();
        }
    }
}

Danke schon mal für euere Mühe.

MfG

DerNetteNachbar

Moderiert von user profile iconmatze: Beiträge zusammengefasst
SvenAbeln
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 334
Erhaltene Danke: 3



BeitragVerfasst: Di 13.10.09 15:18 
Es gibt hier im Forum die Möglichkeit einen Post zu editieren, das wäre übersichtlicher als deine 3 Posts.

Zu deiner Frage:

Warum 'Post' und direkt danach ein 'Get'?
ausblenden Delphi-Quelltext
1:
2:
  strXMLResponse := IdHTTP.Post(strURL2Interface, s);
  strXMLResponse := IdHTTP.Get(strURL2Interface);

Post alleine sollte doch reichen.
DerNetteNachbar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 224



BeitragVerfasst: Di 13.10.09 17:33 
Also einfach die GET Methode igonieren;-)War nur ein Versuch
DerNetteNachbar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 224



BeitragVerfasst: Do 15.10.09 09:10 
PUSH
DerNetteNachbar Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 224



BeitragVerfasst: Mo 19.10.09 09:44 
PUSH