Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHP Soap not loading WSDL from remote server

Posted on 2011-10-03
8
Medium Priority
?
3,310 Views
Last Modified: 2012-08-14
I'm trying to access the following SOAP service on a different server (animplant.com):

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

using the following php code on my server:

$client = new SoapClient('http://www.animplant.com:8080/rmb/rmbService?wsdl');

however, I keep getting the following error:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.animplant.com:8080/rmb/rmbService?wsdl' : Start tag expected, '<' not found

The strange thing is that I can load the xml in a browser fine. And even stranger, when I copy the xml file to the same server as the php code, php can process it.

Any ideas what the problem is?

Thanks
0
Comment
Question by:hbiz
8 Comments
 
LVL 12

Expert Comment

by:zappafan2k2
ID: 36907823
Hmm, on my server, this
<?php
$client = new SoapClient('http://www.animplant.com:8080/rmb/rmbService?wsdl');
print_r($client->__getFunctions());

Open in new window

produced this:
Array
(
    [0] => getResultResponse getResult(getResult $parameters)
    [1] => addTrainingDataResponse addTrainingData(addTrainingData $parameters)
    [2] => getTrainingDataResponse getTrainingData(getTrainingData $parameters)
)

Open in new window


Is there anything else in your server logs?  Have you tried
ini_set('error_reporting', E_ALL);

Open in new window

to see if there's a better explanation for what's going on?
0
 

Author Comment

by:hbiz
ID: 36907873
I tried adding that ini_set() and I still the get the same SOAP error:

500 | Internal Server Error | SoapFault
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.animplant.com:8080/rmb/rmbService?wsdl' : Start tag expected, '<' not found


I have no clue what's going on. I can't get past the constructor for SoapClient
0
 

Author Comment

by:hbiz
ID: 36907890
I've also tried setting up a new account on a free hosting site (000webhost) and ran your php code and got the same error:

http://jumpstarmedia.host22.com/test.php

code:

<?php
ini_set('error_reporting', E_ALL);

$client = new SoapClient('http://www.animplant.com:8080/rmb/rmbService?wsdl');
print_r($client->__getFunctions());
?>
0
When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot has fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 36909249
Some of my colleagues say that SOAP is the devil.  I do not go quite that far, but I know that the internet is littered with the dessicated rotting husks of failed SOAP projects.  In contrast, I have never seen a RESTful interface that you could not understand and use immediately with great success.  So my recommendation is to contact the web service provider and ask if they have a REST interface that you can use, instead of the SOAP interface.  You can learn more (than you ever need to know) about REST interfaces here.  
http://en.wikipedia.org/wiki/Representational_state_transfer

A good example of a RESTful web service is the Yahoo Geocoder.  Look it up to see how easy it can be to use REST.  I do not even have SOAP in my PHP installation, that's how little I think of it!

If you want to see what "animplant" is giving you back, you can look at this.
http://www.laprbass.com/RAY_temp_hbiz.php
<?php // RAY_temp_hbiz.php
error_reporting(E_ALL);
echo "<pre>";

$xml = file_get_contents('http://www.animplant.com:8080/rmb/rmbService?wsdl');
echo htmlentities($xml);

Open in new window

0
 

Author Comment

by:hbiz
ID: 36914646
Thanks for the help everyone. I managed to get the service provider to switch to port 80 and PHP was able to process the wsdl url.

My next problem is that I'm unable to use one of the functions (getResult)

Using this testing page as an example:

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

I'm sending the following request:

$net = new SoapClient("http://www.animplant.com/rmb/rmbService?wsdl");
print_r($net->getResult('10',0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2))

however, I get a java null exception.

I figured that was a bug on their end, however, when I put those values in the testing page, it works correctly.

Am I formatting my request parameters incorrectly?

Thanks
0
 
LVL 12

Expert Comment

by:zappafan2k2
ID: 36914674
Have you tried putting the arguments into an array and using the __soapcall function?
http://us2.php.net/manual/en/soapclient.soapcall.php
0
 

Author Comment

by:hbiz
ID: 36914736
unfortunately that yields the same results:

print_r($net->__soapCall('getResult', array('10',0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2)));



500 | Internal Server Error | SoapFault
java.lang.NullPointerException

0
 
LVL 16

Accepted Solution

by:
Rose Babu earned 2000 total points
ID: 37060930
Hi,

have a look on the  below php soap client sample code.

it returns the response. (addTrainingData returns empty response data and getResult returns some response data)

<?php
ini_set('error_reporting', E_ALL);

$client = new SoapClient('http://www.animplant.com:8080/rmb/rmbService?wsdl');

// Call addTrainingData
echo "<u>addTrainingData Response</u><br /><br />";
$arrParameters = 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', 'target' => '0.2');
$response = $client->addTrainingData($arrParameters);

print_r($response); // $response -> addTrainingDataResponse);

echo "<br /><br /><br />";

// Call getResult
echo "<u>getResult Response</u> <br /><br />";
$arrParameters = 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');
$response = $client->getResult($arrParameters);

print_r($response); // $response -> getResultResponse);
?>

Open in new window

hope this may help you...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

581 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