pser Posted March 19, 2007 Share Posted March 19, 2007 Hi, I've been asked to create and establish a connection towards a system with a SOAP server. The company hosting the external application has provided me with example code of how to connect in .NET and Java. I don't have any skill in Java so I've tried to understand the .NET example and create the same thing in PHP. So far i'm just getting a error message and the company who has provided the example doesn't have any who can support me within PHP. I hope someone here has the ability to give me a hand. The .NET code starts like this: static EPMService epm; static AuthenticationCredentials credentials; static UserCenterRecord userCenterRecord; private static String read (String prompt) { Console.Write(prompt + ": "); return Console.ReadLine(); } public static void Main (string[] args) { String epmURL; String username; String password; /*epmURL = read("Enter the URL of the EPM application"); username = read("Username"); password = read("Password"); */ epmURL = "http://localhost/71"; username = "admin"; password = "admin"; epm = new EPMService(); epm.Url = epmURL + "/services/EPM"; credentials = new AuthenticationCredentials(); credentials.username = username; credentials.password = password; // Test the EPM connection Console.WriteLine("Testing EPM connection."); String input = ""+System.DateTime.Now; String output = epm.echo(input); if (input != output) { Console.WriteLine("echo() method failed to return the same string."); return; } ProductVersion pv = epm.getProductVersion(); Console.WriteLine(""); Console.WriteLine("----- Product Version Information -----"); Console.WriteLine(" Stream : " + pv.stream); Console.WriteLine(" Version : " + pv.version); Console.WriteLine(" Build : " + pv.build); public partial class AuthenticationCredentials { private string passwordField; private string usernameField; /// <remarks/> [system.Xml.Serialization.SoapElementAttribute(IsNullable=true)] public string password { get { return this.passwordField; } set { this.passwordField = value; } } /// <remarks/> [system.Xml.Serialization.SoapElementAttribute(IsNullable=true)] public string username { get { return this.usernameField; } set { this.usernameField = value; } } } --------------------------- I have found a class named Webservices which I have tried both nusoap and PEAR and get the following error: soap_fault Object ( [error_message_prefix] => [mode] => 1 [level] => 1024 => WSDLPARSER [message] => Unable to parse WSDL file https://hosting2.halogensoftware.com/roxar/services/EPM XML error on line 2: junk after document element [userinfo] => [backtrace] => Array ( [0] => Array ( [file] => /usr/share/pear/SOAP/Fault.php [line] => 63 [function] => pear_error [class] => pear_error [type] => :: [args] => Array ( [0] => Unable to parse WSDL file https://hosting2.halogensoftware.com/roxar/services/EPM XML error on line 2: junk after document element [1] => WSDLPARSER [2] => [3] => [4] => ) ) -------------------------------------- This is the simple code I've created just to establish connection and try to get the server respond: $options = array( 'wsdl' => 'https://hosting2.halogensoftware.com/roxar/services/EPM', //'authentication' => 'headers', 'implementation' => 'pearsoap', 'soapoptions' => array('trace'=>1,'exceptions'=>0) ); $credentials = array( 'username' => '<username>', 'password' => '<password>' ); $service =& new Webservices($options,'<username>','<password>'); $result = $service->call('echo','test'); $result = $service->call('getProductVersion'); //$result = $service->call('userView',array('userid'=>0)); if ($service->error !== false) { echo "<b>Error:</b> "; echo "<pre>"; print_r($service->error); echo "</pre>"; } else { echo "<b>Result:</b> "; echo "<pre>"; print_r($result); echo "</pre>"; } $service->logout(); As you can see of the code there been allot of editing and thing are shown up double. So anyone out there who can help direct me so I can solve this problem. Thanks Paal Link to comment https://forums.phpfreaks.com/topic/43328-php-vs-soap/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.