0

I know taht there already are many question about this subject but I haven't find the solution for my problem.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Header>
        <PeopleCountingServiceHeader xmlns="http://localhost/countingws/">
            <Username>username</Username>
            <Password>password</Password>
            <Camera>essai</Camera>
        </PeopleCountingServiceHeader>
    </soap:Header>
    <soap:Body>
        <InsertData xmlns="http://ai-sense.com/counting/">
            <impacts>
                <Impact>
                    <TimeStamp>2014-10-23T15:17:51.879</TimeStamp>
                    <Type>Output</Type>
                    <Layer>0</Layer>
                </Impact>
                <Impact>
                    <TimeStamp>2014-10-23T15:17:52.753</TimeStamp>
                    <Type>Input</Type>
                    <Layer>0</Layer>
                </Impact>
                <Impact>
                    <TimeStamp>2014-10-23T15:17:54.375</TimeStamp>
                    <Type>Output</Type>
                    <Layer>0</Layer>
                </Impact>
                <Impact>
                    <TimeStamp>2014-10-23T15:17:55.186</TimeStamp>
                    <Type>Input</Type>
                    <Layer>0</Layer>
                </Impact>
                <Impact>
                    <TimeStamp>2014-10-23T15:18:28.897</TimeStamp>
                    <Type>Output</Type>
                    <Layer>0</Layer>
                </Impact>
                <Impact>
                    <TimeStamp>2014-10-23T15:18:29.771</TimeStamp>
                    <Type>Input</Type>
                    <Layer>0</Layer>
                </Impact>
                <Impact>
                    <TimeStamp>2014-10-23T15:22:41.219</TimeStamp>
                    <Type>Output</Type>
                    <Layer>0</Layer>
                </Impact>
            </impacts>
        </InsertData>
    </soap:Body>
</soap:Envelope>

And I want to retrieve for example the username.

I have already try somethinf like this :

$request =simplexml_load_file("php://input", NULL, TRUE);
echo "request: "$request->{"soap:Header"}->PeopleCountingServiceHeader->Username;

How can I access to my datas ?

5
  • This is not just XML, but SOAP. Have you read about ext/soap? Commented Oct 24, 2014 at 9:49
  • @ThW No didn't know that there is a direference ^^ I will take a look. Commented Oct 24, 2014 at 9:50
  • @ThW Humm I'm not actually shure of what is SOAP... Commented Oct 24, 2014 at 9:54
  • SOAP is an XML format to transfer objects between systems. See en.wikipedia.org/wiki/SOAP . You could parse it manually, but a specific SOAP implementation is a lot more convenient. Commented Oct 24, 2014 at 10:01
  • @ThW Thank you a lot, I'm trying to learn how to use it; it's a bit more complicated than I was figuring me :-P If you can post this as answer, I will be able to mark it as solution Commented Oct 24, 2014 at 10:20

1 Answer 1

1

This is not just XML, but SOAP. PHP has a specific extension for it: ext/soap.

SOAP is an XML format to transfer objects between systems. You could parse it manually, but a specific SOAP implementation is a lot more convenient.

If you parse in manually you have to consider the namespaces. Here are 3 namespaces in your example XML:

  1. http://schemas.xmlsoap.org/soap/envelope/ - the SOAP envelope, using a soap prefix/alias
  2. http://localhost/countingws/ - elements inside soap:Header, no prefix/alias
  3. http://ai-sense.com/counting/ - elements inside soap:Body, no prefix/alias
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your quick answer ! I will search about how to use namespaces with SimpleXMLElement php class

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.