I am trying to create a soap connection , however I'm getting an error when I try and create an instance of the soap client class.

$client = new SoapClient("exampleaddress.wsdl",
        array(  'login'      => 'xxx',
                'password' => 'xxxx',
             )
			);

The error is

Fatal error: Uncaught SoapFault exception: [prefix1:MessageInformationHeaderRequired]

xxxxx.Addressing.AddressingFault: Message Information Header Required at
xxxxx.Messaging.SoapHttpRouter.ProcessRequestMessage(SoapEnvelope message) at
xxxxx.Messaging.SoapHttpRouter.RoutingAsyncResult.ForwardRequest() at
xxxxx.Messaging.SoapHttpRouter.RoutingAsyncResult..ctor(SoapHttpRouter parent, HttpContext httpContext, AsyncCallback callback,
 Object asyncState) in siteaddress\pagename.php:13 Stack trace: #0 siteaddress\pagename.php(13):
 SoapClient->__call('getPDF', Array) #1 siteaddress\pagename.php(13):
 SoapClient->getPDF(Array) #2 {main} thrown in siteaddress\pagename.php on line 13

Thanks

    From the error it seems like you're not getting a proper wsdl back. I'd check your authentication and also enable debugging and look at the actual XML that is being transmitted back and forth. Posting the actual request and response would be helpful if your authentication is correct.

      first of all thanks so much for your time bpat1434. actually i am new in php soap. i have idea how to get info once i access wsdl. but problem is that i am unable to connect. i could not understand exactly your answer. there may be a reason that username and password is not correct??? what could be any other reason.

      i also want to inform you that service is based on Web Services Enhancements (WSE) 3.0 for Microsoft.

      Please let me know if i am not clear in my question. i will be very thankful to you. i badly need to complete this work in time. Thanks again

      one more thing. how we will know authentication domain? it exists in wsdl file somewhere or client need to tell us separately?

        I would check that the username and password are correct and the URL to the WSDL file is correct. If you are certain they are correct, I'd wonder what authentication mechanism it's using. It may not be basic authentication, it may be Digest in which case you'd have to add the key "authentication" with the value SOAP_AUTHENTICATION_DIGEST to your constructor array:

        $client = new SoapClient(
            "some.wsdl",
            array
            (
                "login" => "myusername",
                "password" => "mypassword",
                "authentication" => SOAP_AUTHENTICATION_DIGEST, // Or SOAP_AUTHENTICATION_BASIC,
        
        )
        );

          I would check that the username and password are correct and the URL to the WSDL file is correct. If you are certain they are correct, I'd wonder what authentication mechanism it's using. It may not be basic authentication, it may be Digest in which case you'd have to add the key "authentication" with the value SOAP_AUTHENTICATION_DIGEST to your constructor array:

          $client = new SoapClient(
              "some.wsdl",
              array
              (
                  "login" => "myusername",
                  "password" => "mypassword",
                  "authentication" => SOAP_AUTHENTICATION_DIGEST, // Or SOAP_AUTHENTICATION_BASIC
              )
          );

            It appears the WSDL is open so no authentication is necessary. Everything worked in my test when I set up the code. I could even strip it down to just passing the WSDL to the constructor and no other options.

            Each time received 10 functions I could run:

            getVedbandayfirlitFasteignarResponse getVedbandayfirlitFasteignar(getVedbandayfirlitFasteignar $parameters) (107 byte string)
            getPDFResponse getPDF(getPDF $parameters) (41 byte string)
            getVedbandayfirlitOkutaekisResponse getVedbandayfirlitOkutaekis(getVedbandayfirlitOkutaekis $parameters) (104 byte string)
            isEignStadfestILandskraResponse isEignStadfestILandskra(isEignStadfestILandskra $parameters) (92 byte string)
            getEignastadaResponse getEignastada(getEignastada $parameters) (62 byte string)
            getVedbandayfirlitFasteignarResponse getVedbandayfirlitFasteignar(getVedbandayfirlitFasteignar $parameters) (107 byte string)
            getPDFResponse getPDF(getPDF $parameters) (41 byte string)
            getVedbandayfirlitOkutaekisResponse getVedbandayfirlitOkutaekis(getVedbandayfirlitOkutaekis $parameters) (104 byte string)
            isEignStadfestILandskraResponse isEignStadfestILandskra(isEignStadfestILandskra $parameters) (92 byte string)
            getEignastadaResponse getEignastada(getEignastada $parameters) (62 byte string)

            Is the error you're seeing happening when you call a function?

              yes it happens when i call a function. before calling a function i can see the list of functions. but when i call a function than that error appeared

                I am trying to create a soap connection , however I'm getting an error when I try and create an instance of the soap client class.

                $client = new SoapClient("exampleaddress.wsdl",
                        array(  'login'      => 'xxx',
                                'password' => 'xxxx',
                             )
                            );
                

                after this i am able to see a list of function using

                var_dump($client->__getFunctions());
                

                but when i call any function error appears

                Fatal error: Uncaught SoapFault exception: [prefix1:MessageInformationHeaderRequired]
                
                xxxxx.Addressing.AddressingFault: Message Information Header Required at
                xxxxx.Messaging.SoapHttpRouter.ProcessRequestMessage(SoapEnvelope message) at
                xxxxx.Messaging.SoapHttpRouter.RoutingAsyncResult.ForwardRequest() at
                xxxxx.Messaging.SoapHttpRouter.RoutingAsyncResult..ctor(SoapHttpRouter parent, HttpContext httpContext, AsyncCallback callback,
                 Object asyncState) in siteaddress\pagename.php:13 Stack trace: #0 siteaddress\pagename.php(13):
                 SoapClient->__call('getPDF', Array) #1 siteaddress\pagename.php(13):
                 SoapClient->getPDF(Array) #2 {main} thrown in siteaddress\pagename.php on line 13
                

                any help will be greatly appreciated

                  It's either on their side or you're not passing the correct arguments to the soap function. I get the same result. I don't have any real data to test with, but I'm willing to bet that once you call the correct function with the correct parameters you will get a valid response.

                    Thanks bpat for your reply. bpat i worked some other wsdl files. May be you are right but normally when a wrong function is called than error appears

                     Fatal error: Uncaught SoapFault exception: [Client] Function ("function name") is not a valid method for this service
                    

                    and when a wrong parameters is passed then error appears

                    Fatal error: SOAP-ERROR: Encoding: object has no 'variable name'(parameter name which should called) property
                    
                      6 days later

                      Looks like you need to specify some extra headers in your SOAP call. See Web Services Addressing @ W3C for more information. If you are not aware of the values, then whomever provides the service should be able to give you instruction on what they should be.

                      You can add the headers like so:

                      <?php
                      	$client = new SoapClient(
                      		"http://ws-test.fmr.is/SvcThinglysingar_0301/Thinglysingar_0301.wsdl",
                      		array
                      		(
                      			"trace" => true,
                      			"exceptions" => true
                      		)
                      	);
                      
                      try
                      {
                      	$headers = array();
                      	$headers[] = new SoapHeader("http://schemas.xmlsoap.org/ws/2004/08/addressing", "destination", "http://www.google.com");
                      	$headers[] = new SoapHeader("http://schemas.xmlsoap.org/ws/2004/08/addressing", "action", "http://ws-test.fmr.is/SvcThinglysingar_0301/Thinglysingar_0301.wsdl");
                      
                      	$client->__setSoapHeaders($headers);
                      
                      	$response = $client->getVedbandayfirlitFasteignar(
                      		array
                      		(
                      			"FastaNr" => "This is a test",
                      			"bGeneratePDF" => false
                      		)
                      	);
                      }
                      catch (Exception $e)
                      {
                               var_dump($e);
                          }
                      

                        thanks bpat1434

                        let me check

                        i could not reply you earlier because i could not receive email alert of you message. otherwise i was waiting for your reply for many days🙂

                          Write a Reply...