Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    New Coder
    Join Date
    Feb 2008
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Question SOAP not connecting

    I have a web service that a co worker of mine wrote. I'm trying to connect to it and use the data from it to display selections in a selection box.

    It doesn't connect to the service though. The WSDL file has been created and can be displayed in the browser: http://sqlsvr1/RefrigerantCompliance.../Service1.WSDL

    Here's my code:
    Code:
    $client = new SoapClient("http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL");
    $result = $client->GetJobs();
    It brings up all kinds of errors:
    Warning: SoapClient::SoapClient() [soapclient.soapclient]: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\My Dropbox\compliance\tester2.php on line 4

    Warning: SoapClient::SoapClient(http://sqlsvr1/RefrigerantCompliance.../Service1.WSDL) [soapclient.soapclient]: failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\My Dropbox\compliance\tester2.php on line 4

    Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL" in C:\EDITED\EDITED\tester2.php on line 4

    Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL' : failed to load external entity "http://sqlsvr1/RefrigerantComplianceService/Service1.WSDL" in C:\EDITED\tester2.php:4 Stack trace: #0 C:\EDITED\EDITED\tester2.php(4): SoapClient->SoapClient('http://sqlsvr1/...') #1 {main} thrown in C:\EDITED\tester2.php on line 4
    What is going on here? I tried connecting to other public web services like amazon and it works without error.

    Also have PHP5 and SOAP installed.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    This is an invalid domain: http://sqlsvr1/RefrigerantComplianceService
    If the domain cannot be resolved, use the IP address for it instead.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    New Coder
    Join Date
    Feb 2008
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    This is an invalid domain: http://sqlsvr1/RefrigerantComplianceService
    If the domain cannot be resolved, use the IP address for it instead.
    Thanks for the response and sorry for the delay...

    The web service is only on our network and not public which is why it wasn't working so I've posted the WSDL file below:
    Code:
      <?xml version="1.0" encoding="utf-8" ?> 
    - <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    - <wsdl:types>
    - <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
    + <s:element name="HelloWorld">
      <s:complexType /> 
      </s:element>
    + <s:element name="HelloWorldResponse">
    - <s:complexType>
    + <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" /> 
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:element name="GetJobs">
      <s:complexType /> 
      </s:element>
    - <s:element name="GetJobsResponse">
    - <s:complexType>
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="GetJobsResult" type="tns:ArrayOfJobDAO" /> 
      </s:sequence>
      </s:complexType>
      </s:element>
    - <s:complexType name="ArrayOfJobDAO">
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="JobDAO" nillable="true" type="tns:JobDAO" /> 
      </s:sequence>
      </s:complexType>
    - <s:complexType name="JobDAO">
    - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="StatusCode" type="s:string" /> 
      <s:element minOccurs="1" maxOccurs="1" name="SRPWOHRID" type="s:int" /> 
      <s:element minOccurs="1" maxOccurs="1" name="CompanyNumber" type="s:int" /> 
      <s:element minOccurs="1" maxOccurs="1" name="DivisionNumber" type="s:int" /> 
      <s:element minOccurs="1" maxOccurs="1" name="CustomerNumber" type="s:int" /> 
      <s:element minOccurs="1" maxOccurs="1" name="RequestNo" type="s:int" /> 
      <s:element minOccurs="0" maxOccurs="1" name="RequestorName" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="AreaCode" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="PhoneNo" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Address1" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Address2" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="City" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="StateCode" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="RequestType" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="CustomerPONumber" type="s:string" /> 
      <s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string" /> 
      </s:sequence>
      </s:complexType>
      </s:schema>
      </wsdl:types>
    + <wsdl:message name="HelloWorldSoapIn">
      <wsdl:part name="parameters" element="tns:HelloWorld" /> 
      </wsdl:message>
    + <wsdl:message name="HelloWorldSoapOut">
      <wsdl:part name="parameters" element="tns:HelloWorldResponse" /> 
      </wsdl:message>
    - <wsdl:message name="GetJobsSoapIn">
      <wsdl:part name="parameters" element="tns:GetJobs" /> 
      </wsdl:message>
    - <wsdl:message name="GetJobsSoapOut">
      <wsdl:part name="parameters" element="tns:GetJobsResponse" /> 
      </wsdl:message>
    - <wsdl:portType name="Service1Soap">
    - <wsdl:operation name="HelloWorld">
      <wsdl:input message="tns:HelloWorldSoapIn" /> 
      <wsdl:output message="tns:HelloWorldSoapOut" /> 
      </wsdl:operation>
    - <wsdl:operation name="GetJobs">
      <wsdl:input message="tns:GetJobsSoapIn" /> 
      <wsdl:output message="tns:GetJobsSoapOut" /> 
      </wsdl:operation>
      </wsdl:portType>
    - <wsdl:binding name="Service1Soap" type="tns:Service1Soap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    - <wsdl:operation name="HelloWorld">
      <soap:operation soapAction="http://tempuri.org/HelloWorld" style="document" /> 
    - <wsdl:input>
      <soap:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="GetJobs">
      <soap:operation soapAction="http://tempuri.org/GetJobs" style="document" /> 
    - <wsdl:input>
      <soap:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:binding name="Service1Soap12" type="tns:Service1Soap">
      <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    - <wsdl:operation name="HelloWorld">
      <soap12:operation soapAction="http://tempuri.org/HelloWorld" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
    - <wsdl:operation name="GetJobs">
      <soap12:operation soapAction="http://tempuri.org/GetJobs" style="document" /> 
    - <wsdl:input>
      <soap12:body use="literal" /> 
      </wsdl:input>
    - <wsdl:output>
      <soap12:body use="literal" /> 
      </wsdl:output>
      </wsdl:operation>
      </wsdl:binding>
    - <wsdl:service name="Service1">
    - <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
      <soap:address location="http://sqlsvr1/RefrigerantComplianceService/Service1.asmx" /> 
      </wsdl:port>
    - <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12">
      <soap12:address location="http://sqlsvr1/RefrigerantComplianceService/Service1.asmx" /> 
      </wsdl:port>
      </wsdl:service>
      </wsdl:definitions>
    I have been given this web service, which I have been told will create an XML file once it is called through code, but I don't know how to get the XML from the web service in PHP.

    This is what I have so far, but the second line returns an error and I don't think it's at all right...

    PHP Code:
        $client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl");
       
    $result $client->GetJobs(array()); 
    My goal is to make a dynamic dropdown list that connects to another one of our servers using a web service.

    How do I get this to return an XML file with the data that I can use to add to the drop down box?

  • #4
    New Coder
    Join Date
    Feb 2008
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts
    If anyone would like to help, it would be much appreciated...

    From what I've been reading and looking at a few examples I've gotten this so far, but it still throws errors:

    PHP Code:
       $client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl");
        
    $result $client->GetJobs(array('GetJobs'));         //Error occurs on this line

        // Note that $array contains the result of the traversed object structure
         
    $array $result->GetJobsResult->JobDAO;
        print 
    "Service Description:<select><option>Please Select One</option>";
        foreach(
    $array as $k=>$v){
            print 
    "<option>".($k+1).$v->RequestNo."</option>".$v->Description."</td></tr>";
        }
        print 
    "</select>"
    Error:
    Fatal error: Uncaught SoapFault exception: [HTTP] Not Found in C:\xampp\htdocs\compliance\tester2.php:46
    Stack trace:
    #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://sqlsvr1/...', 'http://tempuri....', 1, 0)
    #1 [internal function]: SoapClient->__call('GetJobs', Array)
    #2 C:\xampp\htdocs\compliance\tester2.php(46): SoapClient->GetJobs('description')
    #3 {main}
    thrown in C:\xampp\htdocs\compliance\tester2.php on line 46
    Last edited by Ty44ler; 01-20-2010 at 08:40 PM.

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    That looks like the wsdl file choking now. Same problem would be my guess, the http://sqlsvr1 cannot be resolved to a host. You can replace this with a domain or ip address though.
    Technically, you do not need a wsdl in order to write web services. You just need to know what to expect.
    Check out the __construct method of the SOAPClient class in the api, one of the examples should show you how to construct the service without a wsdl.
    Best I can tell (and its been awhile since I've read wsdl files), the getJobs is a no parameter method, so you shouldn't need to provide it with any arguments. You'll need to get through the whole resolution problem first though.

    Edit:
    Mkay, so a little alteration from the above. The error message on an invalid domain is 'Could not connect to host'. When I have the correct host with an incorrect path to a soap server, the message is 'Not Found', same as you have. These are not triggered on construct as I expected, rather they are triggered on call.
    So, it looks like all you need to do is ensure that the path to the file is correct from you're http root. The host is fine in this case with http://refrigerantcompliance, but the path from there appears to be invalid.
    Last edited by Fou-Lu; 01-21-2010 at 12:42 AM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    New Coder
    Join Date
    Feb 2008
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Yes, I thought that was the case as well, but I tried it on a server within our network and the WSDL showed up. I believe it can only be accessed within our firewall (which is fine since the service will only be run on our intranet).

    If I were wanting to just display all the data in "description" from JobDAO would that be possible?

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Yeah, but its been a long time myself since I did soap work, so you'll need to play around with you're results to see what datatypes and storage are in use. I'm thinking it should be a returned associative array.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    New Coder
    Join Date
    Feb 2008
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I appreciate your help. I might be in over my head on this one. This is my first time ever attempting SOAP.

    The problem is I'm not really getting any results, just errors and when I do, I'm not exactly sure what they mean.

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    var_dump anything you need, it will give you an idea of the internal storage structure.
    So if you make it past this:
    PHP Code:
    $result $client->getJobs(); // Or $client->__soapCall('getJobs'); i believe is the technically 'correct' route 
    without triggering a soap fault, the problem is later in the handling. Dump the $result to see exactly what it is:
    PHP Code:
    var_dump($result); 
    It should tell you if its an object or string or array or whatever. My suspicion is it will be an array since there is no classmap on you're client indicating it should be an object.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #10
    New Coder
    Join Date
    Feb 2008
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts
    There was no Soap Fault!

    PHP Code:
    $client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl", array("trace" => 1));
    $result $client->__soapCall('getJobs');


    echo 
    "<pre>\n";
    var_dump($result);
    echo 
    "</pre>"
    But there was an error...

    Returns:

    Warning: SoapClient::__soapCall() expects at least 2 parameters, 1 given in C:\xampp\htdocs\compliance\tester2.php on line 44

    Fatal error: SoapClient::__soapCall() [<a href='soapclient.--soapcall'>soapclient.--soapcall</a>]: Invalid parameters in C:\xampp\htdocs\compliance\tester2.php on line 44
    So it's saying it needs two parameters, but I didn't believe that there were any parameters needed?
    Last edited by Ty44ler; 01-21-2010 at 02:53 PM.

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    yes my bad, when you use the __soapCall, it expects to always have a argument.
    So, with __soapCall like so:
    PHP Code:
    $soapClient->__soapCall('mynoparamfunc', array());
    $soapClient->__soapCall('myparamedfunc', array('oneparam'));

    // with __call:
    $soapClient->mynoparamfunc();
    $soapClient->myparamedfunc('oneparam'); 
    Although the __call approach is easier, its been deprecated in the api in favour of the __soapCall approach. I cannot tell you why they chose to do this.

    On the plus side, you're above is looking good now, the errors are complaining about parameter conflictions, indicating that you're calls are now successful (though failing lol).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #12
    New Coder
    Join Date
    Feb 2008
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Unhappy

    I really do appreciate you helping me out with this, you've been amazing just with what you've helped me out with so far even if there are still errors. I've gotten further now than I have on my own.


    I took what you wrote, assuming that the one I needed was the with 'mynoparamfunc' since my function has no parameters. I placed it within my code like so:
    PHP Code:
    $client = new SoapClient("http://refrigerantcompliance/RefrigerantComplianceService/Service1.wsdl");
    $result $client->__soapCall('GetJobs', array()); 
    but now, I get a SoapFault Exception...

    Fatal error: Uncaught SoapFault exception: [HTTP] Not Found in C:\xampp\htdocs\compliance\tester2.php:47
    Stack trace:
    #0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://sqlsvr1/...', 'http://tempuri....', 1, 0)
    #1 [internal function]: SoapClient->__call('GetJobs', Array)
    #2 C:\xampp\htdocs\compliance\tester2.php(47): SoapClient->GetJobs()
    #3 {main}
    thrown in C:\xampp\htdocs\compliance\tester2.php on line 47
    Did I misunderstand the code or am I screwing something up?
    Last edited by Ty44ler; 01-21-2010 at 03:53 PM.

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Nope, this is the same error I was getting when I couldn't actually attach to a soapserver.
    Instead of using the wsdl, try non-wsdl mode instead. To me, it appears that the Service1.wsdl file is pointing to the incorrect location for where the services are being served from (http://sqlsvr1/RefrigerantCompliance.../Service1.asmx). You can also try to type that manually into you're browser to see if you get a soap response.
    Non-wsdl mode would be like so:
    PHP Code:
    $aOptions = array(
        
    'location' => 'http://webpath/to/service',
        
    'uri' => 'http://tempuri.org/'
    );
    $client = new SOAPClient(null$aOptions); 
    You'll need to play with the location, to me it appears that the path (RefrigerantComplianceService/Service1.asmx) is invalid for the service. I cannot help you with the correct path I'm afraid, but since its internal you should be able to either browse it or find out the correct location. If this location is correct, I'll need to think about this a little more.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #14
    New Coder
    Join Date
    Feb 2008
    Posts
    57
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I may have messed you up, the address changed from sqlsrvr to refrigerantcompliance midway through this discussion. Sorry I didn't mention that...

    But, the path seems correct:


    I do believe that trying non-wsdl mode helped. It gave a different error as it said it did not recognize the value of the HTTP Header SOAPAction. Is that error due to the code or the address?

    Here's my code now:
    PHP Code:
    $aOptions = array(
        
    'location' => 'http://refrigerantcompliance/RefrigerantComplianceService/Service1.asmx',
        
    'uri' => 'http://tempuri.org/'
    );
    $client = new SOAPClient(null$aOptions);  

    $result $client->__soapCall('GetJobs', array()); //line 51 
    and the error:
    Fatal error: Uncaught SoapFault exception: [soap:Client] Server did not recognize the value of HTTP Header SOAPAction: http://tempuri.org/#GetJobs. in C:\xampp\htdocs\compliance\tester2.php:51
    Stack trace:
    #0 C:\xampp\htdocs\compliance\tester2.php(51): SoapClient->__soapCall('GetJobs', Array)
    #1 {main}
    thrown in C:\xampp\htdocs\compliance\tester2.php on line 51
    Last edited by Ty44ler; 01-21-2010 at 04:18 PM.

  • #15
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    (Image is blocked by the work firewall from the looks of it)
    Mkay, lets try a manual setting of the soap action:
    PHP Code:
    $result $client->__soapCall('GetJobs', array(), array('soapaction' => 'http://tempuri.org/GetJobs')); 
    That work? Looks to me like its the WSDL file causing the problems with incorrect targets.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    Ty44ler (01-21-2010)


  •  
    Page 1 of 2 12 LastLast

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •