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="
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
--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,'
$response_string=substr($response,$start,$end-$start+1);
return($response_string);
}
}