Solutions to various problems encountered by PHP5 when calling JAVAWebService _ PHP Tutorial

Source: Internet
Author: User
Solutions to various problems encountered by PHP5 when calling JAVAWebService. Start gank. Server: Spring3.0.5 + CXF2.4 and JDK1.6 should be automatically generated. The wsdl file server is not the first problem encountered by our client: PHP5.1.3: SOAP-ERROR: Enco start gank.

Server:

Spring3.0.5 + CXF2.4, JDK1.6

"Should be" automatically generated wsdl file <服务端不是我们的>

Client:

PHP5.1.3

The first problem encountered:

SOAP-ERROR: Encoding: object has no 'id' property

However, no id is required in the API documentation to view the content of the wsdl file.

View the schema document as follows:

Through schema, we can use the maxOccurs and minOccurs attributes to define the number of times an element may appear. MaxOccurs defines the maximum number of occurrences of an element, while minOccurs defines the minimum number of occurrences of an element. The default values of maxOccurs and minOccurs are 1! (Okay, this is a server problem? Then I wrote a random value and passed it ...)


PS: There is a small link in the middle. I went to view the source code of PHP...

Model_to_xml_object in php_encoding.c in SOAP

Static int model_to_xml_object (xmlNodePtr node, sdlContentModelPtr model, zval * object, int style, int strict TSRMLS_DC)

// A small piece of code


} Else if (model-> min_occurs = 0 ){
Return 2;
} Else {
If (strict ){
Soap_error1 (E_ERROR, "Encoding: object has no '% s' property", model-> u. element-> name); // It is obviously!
}
Return 0;
}

I found the problem on min_occurs from here, so I solved the problem (isn't the other party very standard ?)


Second question:

Looks like we got no XML document

This is depressing. it has been solved for a long time.

The returned data is in the following format:


HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: multipart/related; type = "application/xop + xml"; boundary = "uuid: 0c37c356-41de-4361-9835-ab8dc023dcac"; start =" "; Start-info =" text/xml"
Content-Length: 790
Date: Tue, 04 Dec 2012 07:57:45 GMT


-- Uuid: 0c37c356-41de-4361-9835-ab8dc023dcac
Content-Type: application/xop + xml; charset = UTF-8; type = "text/xml ";
Content-Transfer-Encoding: binary
Content-ID:
2003 2012-12-04 15:57:46. 124 Logic error Sfn004.cn: when you go to the mall, you will have your own images and images, then you will have your own images and images, and then you will have your own images and images. ℃ Zhjx922.com: when you go to the mall, you will have your own images and images, then you will have your own images and images, and then you will have your own images and images. ℃
-- Uuid: 0c37c356-41de-4361-9835-ab8dc023dcac --
Obviously not XML .. So the PHP boss reported an error.

Ask the recipient. The answer is:

CXF sets the following Upload attributes. The key point is MTOM. php soap extensions do not support this by default.



Baidu, google can be implemented through the WSO2 wsf for php extension, so you can continue looking FOR problems...

Read the official documentation

Http://cn2.php.net/soap

A reply helped me solve the problem. The final solution is as follows:

/**
* Inherits the SoapClient class and overwrites the _ doRequest method.
* @ Author zhjx922
*/
Class ZSoapClient extends SoapClient
{
Public function _ doRequest ($ request, $ location, $ action, $ version, $ one_way = 0)
{
$ Response = parent ::__ doRequest ($ request, $ location, $ action, $ version, $ one_way );

// Handle it according to the actual situation... if yes $ Start = strpos ($ response ,' $ End = strrpos ($ response, '> ');
$ Response_string = substr ($ response, $ start, $ end-$ start + 1 );
Return ($ response_string );
}
}

Bytes. Server: Spring3.0.5 + CXF2.4, JDK1.6 should be the automatically generated wsdl file server, not the first problem we encountered in PHP5.1.3: SOAP-ERROR: Enco...

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.