SoapClient1.2 does not encounter errors when accessing webservice and no response is returned. what is the problem?

Source: Internet
Author: User
SoapClient1.2 does not encounter errors when accessing webservice and no response is returned. what is the problem? Recently, you need to access a. net webservice through PHP. the code is as follows:
$ Client = new SoapClient ("https://myurl.svc? Wsdl ", array ('soap _ version' => SOAP_1_1, 'track' => TRUE, 'exception' => FALSE ));
$ Header = new SoapHeader ("https://myurl.svc", "Authentication", array ('username' => $ UserName, 'password' => $ Password), false );
$ Client->__ setSoapHeaders (array ($ header ));
$ Client-> GetVersion (); // This is a webservice method.
Error:
PHP Fatal error: Uncaught SoapFault exception: [HTTP] Cannot process the message because the content type 'text/xml; charset = utf-8 'was not the expected type' application/soap + xml; charset = utf-8'

After checking some information, it is said that php's soapclient uses version 1.1 by default, and content_type is "text/xml" and changed to version 1.2.
Content_type is "application/soap + xml ".
$ Client = new SoapClient ("https://myurl.svc? Wsdl ", array ('soap _ version' => SOAP_1_2, 'track' => TRUE, 'exception' => FALSE ));
But after the change, the execution does not return any errors, and a timeout message will be prompted after the execution takes a long time.
I don't know why.
Thank you for your reply.


Reply to discussion (solution)

Because the address you provided cannot be accessed, you cannot know what WSDL says.
Of course, the SoapHeader parameter used to verify the user will not appear in the WSDL
You can contact the service provider to confirm that the SoapHeader parameter is correct.

Thanks for the reply from the xuzuning moderator. the address in the above sample code is false. I used an accessible address during the test. The rest may only be a problem with the parameters in the SoapHeader, if the parameter is incorrect and the webservice ssl verification fails, no prompts such as the verification fails will be returned. is there always No returned results? It is difficult for our service providers to contact each other. how do I write https verification based on the user name and password? Which of the following statements can be modified?
$ Header = new SoapHeader ("https://myurl.svc", "Authentication", array ('username' => $ UserName, 'password' => $ Password), false );
$ Client->__ setSoapHeaders (array ($ header ));

Your statement is correct, as long as the parameter is correct

Confirm that the values of username and password are correct. However, there are spaces and characters such as: 'In username. do you have to handle them before they can be transmitted normally? What should I do if I want to handle it?
The username value in the brackets below
[Abcdefg | Thu, 14 Mar 2013 02:30:09 GMT]

Does your user name change at any time?

Yes, the password is changed at the same time. There is a certain encryption method. if the time is verified, there will be a few minutes of tolerance.

Try using CURL instead or fail. I don't know if the method for passing parameters is incorrect. the error prompt and code are:
==== Error message ====
Took 1.530147 seconds to send a request to https: // *****. svc? Wsdl
TuData
Http://www.w3.org/2005/08/addressing/soap/faults:Sendera:BadContextTokenThe security context token is expired or is not valid. The message was not processed.
==== Code ====
$ Data ="



";
$ TuCurl = curl_init ();
Curl_setopt ($ tuCurl, CURLOPT_URL, "https: // *****. svc? Wsdl ");
$ CurlPost = "Username =". $ username. '& Password ='. $ password;
Curl_setopt ($ tuCurl, CURLOPT_POST, 1 );
Curl_setopt ($ tuCurl, CURLOPT_POSTFIELDS, $ curlPost );
Curl_setopt ($ tuCurl, CURLOPT_SSL_VERIFYPEER, 0 );
Curl_setopt ($ tuCurl, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ tuCurl, CURLOPT_POSTFIELDS, $ data );
Curl_setopt ($ tuCurl, CURLOPT_HTTPHEADER, array ("Content-Type: application/soap + xml; charset = utf-8 "));
$ TuData = curl_exec ($ tuCurl );
If (! Curl_errno ($ tuCurl )){
$ Info = curl_getinfo ($ tuCurl );
Echo 'took'. $ info ['total _ time']. 'seconds to send a request to '. $ info ['URL'];
} Else {
Echo 'curl error: '. curl_error ($ tuCurl );
}
Curl_close ($ tuCurl );
Print"
TuData
";
Print_r ($ tuData );

Have you experienced this? You can also give a prompt... Thank you!

Does PHP soapclient support soap 1.2? Why is no feedback requested after soapclient 1.2 is specified?

I also encountered this problem. could you tell me if the problem has been solved by the landlord?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.