?
Solved

PHP soap request xml formatting

Posted on 2011-10-29
9
Medium Priority
?
420 Views
Last Modified: 2012-05-12
Given the following SOAP service:

http://www.animplant.com/rmb/rmbService?wsdl

which requires the following xml format for the getResult function:


    <?xml version="1.0" encoding="UTF-8"?>
    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header/>
    <S:Body>
        <ns2:getResult xmlns:ns2="http://rmb.animplant.com/">
            <x1>0.2</x1>
            <y1>0.2</y1>
            <x2>0.2</x2>
            <y2>0.2</y2>
            <x3>0.2</x3>
            <y3>0.2</y3>
            <x4>0.2</x4>
            <y4>0.2</y4>
            <x5>0.2</x5>
            <y5>0.2</y5>
            <x6>0.2</x6>
            <y6>0.2</y6>
            <x7>0.2</x7>
            <y7>0.2</y7>
            <x8>0.2</x8>
            <y8>0.2</y8>
            <x9>0.2</x9>
            <y9>0.2</y9>
            <x10>0.2</x10>
            <y10>0.2</y10>
            <x11>0.2</x11>
            <y11>0.2</y11>
            <x12>0.2</x12>
            <y12>0.2</y12>
            <x13>0.2</x13>
            <y13>0.2</y13>
            <x14>0.2</x14>
            <y14>0.2</y14>
           </ns2:getResult>
        </S:Body>
    </S:Envelope>

Open in new window


how would I make that request in PHP?
0
Comment
Question by:hbiz
  • 5
  • 4
9 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37051651
You might want to ask the service provider if they offer a REST interface.  SOAP has been abandoned by many of the major players on the WWW because it is too hard to understand and debug.  But that said, you might try using a HEREDOC string notation.

This is an untested example.  You might want to install it, run it, and use "view source" to see what comes out.
<?php 
error_reporting(E_ALL);

$str = <<<HEREDOC
    <?xml version="1.0" encoding="UTF-8"?>
    <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Header/>
    <S:Body>
        <ns2:getResult xmlns:ns2="http://rmb.animplant.com/">
            <x1>0.2</x1>
            <y1>0.2</y1>
            <x2>0.2</x2>
            <y2>0.2</y2>
            <x3>0.2</x3>
            <y3>0.2</y3>
            <x4>0.2</x4>
            <y4>0.2</y4>
            <x5>0.2</x5>
            <y5>0.2</y5>
            <x6>0.2</x6>
            <y6>0.2</y6>
            <x7>0.2</x7>
            <y7>0.2</y7>
            <x8>0.2</x8>
            <y8>0.2</y8>
            <x9>0.2</x9>
            <y9>0.2</y9>
            <x10>0.2</x10>
            <y10>0.2</y10>
            <x11>0.2</x11>
            <y11>0.2</y11>
            <x12>0.2</x12>
            <y12>0.2</y12>
            <x13>0.2</x13>
            <y13>0.2</y13>
            <x14>0.2</x14>
            <y14>0.2</y14>
           </ns2:getResult>
        </S:Body>
    </S:Envelope>
HEREDOC;

echo $str;

Open in new window

0
 

Author Comment

by:hbiz
ID: 37051695
Thank you but how do I submit the request?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37053070
The web service provider should give you an example of how to submit the request.  In the case of RESTful web services, the request data is usually part of the URL, in the GET arguments.

What is the web service all about?  What information or response are you expecting to get?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:hbiz
ID: 37080452
this was answered by the service provider.

Thanks
0
 

Author Comment

by:hbiz
ID: 37080851
I've requested that this question be closed as follows:

Accepted answer: 0 points for hbiz's comment http:/Q_27422037.html#37080452

for the following reason:

this was answered by the service provider
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37080852
We all want to learn from the forum here at EE.  Instead of dumping the question, please post the solution you found, then accept your own answer as the solution.  That way we have an opportunity to learn from your experience.  Thanks, ~Ray
0
 

Accepted Solution

by:
hbiz earned 0 total points
ID: 37081308
sure Ray, here's the solution:

<?php
try {
    $wsdlUrl = "http://192.168.2.8:8080/rmb/rmbService?wsdl";
    $client = new SoapClient($wsdlUrl, array('trace' => 1));
    $response = $client->getResult(array('network' =>'10', 'x1'=>0.2, 'y1'=>0.2,                                                    'x2'=>0.2, 'y2'=>0.2,  
                                                    'x3'=>0.2, 'y3'=>0.2,  
                                                    'x4'=>0.2, 'y4'=>0.2,
                                                    'x5'=>0.2, 'y5'=>0.2,
                                                    'x6'=>0.2, 'y6'=>0.2,
                                                    'x7'=>0.2, 'y7'=>0.2,
                                                    'x8'=>0.2, 'y8'=>0.2,
                                                    'x9'=>0.2, 'y9'=>0.2,
                                                    'x10'=>0.2, 'y10'=>0.2,
                                                    'x11'=>0.2, 'y11'=>0.2,
                                                    'x12'=>0.2, 'y12'=>0.2,
                                                    'x13'=>0.2, 'y13'=>0.2,
                                                    'x14'=>0.2, 'y14'=>0.2));
    $resVars = get_object_vars($response);
    echo $resVars["return"];
} catch (Exception $e) {          
        echo "REQUEST:\n" . $client->__getLastRequest() . "\n";
    echo $e->getMessage();
}
?>
0
 

Author Closing Comment

by:hbiz
ID: 37098997
this is the solution provided by the service provider.
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 37090158
Excellent, thanks! ~Ray
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month16 days, 2 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question