Home > Backend Development > PHP Tutorial > Solutions to various problems encountered by PHP5 when calling JAVA WebService_PHP Tutorial

Solutions to various problems encountered by PHP5 when calling JAVA WebService_PHP Tutorial

WBOY
Release: 2016-07-22 09:02:47
Original
835 people have browsed it

Start ganking.

Server:

Spring3.0.5+CXF2.4, JDK1.6

"Should be" an automatically generated wsdl file

Client:

PHP5.1.3

The first question I encountered:

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

But the API document says that no ID is required, check the content of the wsdl file

Check the schema document and find the following content:

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 both 1! (Okay, is this a problem on the server side? Then I just wrote a value and it passed...)


PS: There is a small link in the middle. I took a look at the source code of PHP. . .

The function 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);//Obviously
}
return 0;
}

I found out from here that the problem occurred in min_occurs, so I solved the above problem (is the other party not very standardized?)


Second question:

looks like we got no XML document

This is frustrating, it took a long time to solve it

The data has been returned, and then I captured the packet (it seems there is a way to display the data directly), and found that the returned data is similar to 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:
20032012-12-04 15:57:46.124Logic error< ;/msg>sfn004.cn:瀵游笧璧Feng纴姝ゅ璖嵝€廃彽奇$Embroidery绔欌€濋獙癇佹湇锷$diXuanfeng鍦ㄥ镙畐腑Adze屼謉鑳 borrow囀娆℃开鍐卋紒zhjx922.com:瀵游第璧璒纴姝ゅyan钖嵝€仃彰equi$embroidery绔欌€濋獙璇佹湇锷$dixuanfeng鍦ㄥ镙锑锑锛屼鑳 borrow啀娆℃开捐沋紒
--uuid:0c37c356-41de-4361-9835-ab8dc023dcac--
Obviously not XML. . So the PHP boss reported an error

Ask the other party, the answer is:

CXF sets the following upload attributes. The key point is MTOM. The PHP SOAP extension does not support this by default



baidu, google can be implemented through WSO2 WSF FOR PHP extension, don’t bother and keep looking. . .

Read the official documentation

http://cn2.php.net/soap

There was a reply that helped me solve the problem. The final solution is as follows:

/**
* Inherit the SoapClient class and override 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);

//Process according to actual situation. . . , if it starts with $start=strpos($response,' $end=strrpos($response,'>');
$response_string=substr($response,$start,$end-$start+1);
return($response_string);
}
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/371863.htmlTechArticle Start ganking. Server: Spring3.0.5+CXF2.4, JDK1.6 The wsdl file should be automatically generated. The server is not our client: PHP5.1.3 The first problem encountered: SOAP-ERROR: Enco...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template