क्या ऐसी कोई जानवर है? सरल SOAP client कि PHP के साथ जहाजों बहु-भाग संदेशों को समझ में नहीं आता है। अग्रिम में धन्यवाद।PHP SOAP क्लाइंट जो बहु-भाग संदेशों को समझता है?
उत्तर
देशी पीएचपी SoapClient
वर्ग बहुखण्डीय संदेशों का समर्थन नहीं करता (और दृढ़ता से सभी WS- * मामलों में सीमित है) और मैं भी मुझे लगता है कि न तो पीएचपी लिखा पुस्तकालयों NuSOAP है और न ही Zend_Soap SOAP संदेश की इस तरह से निपटने कर सकते हैं।
मैं दो समाधान के बारे में सोच सकते हैं:
SoapClient
वर्ग का विस्तार करने औरSoapClient::__doRequest()
विधि के ऊपर लिख वास्तविक प्रतिक्रिया स्ट्रिंग जिसे फिर आप अपने लहर में पार्स कर सकते हैं की पकड़ पाने के लिए।class MySoapClient extends SoapClient { public function __doRequest($request, $location, $action, $version, $one_way = 0) { $response = parent::__doRequest($request, $location, $action, $version, $one_way); // parse $response, extract the multipart messages and so on } }
हालांकि यह कुछ हद तक मुश्किल हो सकता है - लेकिन कोशिश करने लायक है।
PHP के लिए एक अधिक परिष्कृत SOAP क्लाइंट लाइब्रेरी का उपयोग करें। मेरे दिमाग में आने वाला पहला और एकमात्र WSO2 WSF/PHP है जिसमें मूल PHP एक्सटेंशन स्थापित करने की लागत पर SOAP MTOM, WS-Addressing, WS-Security, WS-SecurityPolicy, WS-Secure Conversation और WS-ReliableMessaging शामिल हैं।
का उपयोग करते हुए एस Gehrig दूसरा विचार यहाँ ठीक काम किया।
में अधिकांश मामले, आपके पास एक MIME मल्टीपार्ट संदेश में पैक किया गया एकमात्र संदेश है। उन मामलों में एक "सोपफॉल्ट अपवाद: [क्लाइंट] ऐसा लगता है कि हमें कोई XML दस्तावेज़ नहीं मिला" अपवाद फेंक दिया गया है। यहां निम्न वर्ग को ठीक करना चाहिए:
class MySoapClient extends SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
// strip away everything but the xml.
$response = preg_replace('#^.*(<\?xml.*>)[^>]*$#s', '$1', $response);
return $response;
}
}
बस पिछले सुझाए गए चरणों में और अधिक प्रकाश जोड़ने के लिए। आप प्रारूप निम्नलिखित में प्रतिक्रिया हो रही किया जाना चाहिए
--uuid:eca72cdf-4e96-4ba9-xxxxxxxxxx+id=108
Content-ID: <http://tempuri.org/0>
Content-Transfer-Encoding: 8bit
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body> content goes here </s:Body></s:Envelope>
--uuid:c19585dd-6a5a-4c08-xxxxxxxxx+id=108--
बस (मैं तो स्ट्रिंग कार्यों का उपयोग कर कि regex के साथ महान नहीं कर रहा हूँ)
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
// strip away everything but the xml.
$response = stristr(stristr($response, "<s:"), "</s:Envelope>", true) . "</s:Envelope>";
return $response;
}
पीएचपी प्रलेखन से rafinskipg की सलाह का पालन करें कोड निम्न का उपयोग करें:
MTOM के लिएसमर्थन addign अपनी परियोजना के लिए इस कोड:
<?php
class MySoapClient extends SoapClient
{
public function __doRequest($request, $location, $action, $version, $one_way = 0)
{
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
// parse $response, extract the multipart messages and so on
//this part removes stuff
$start=strpos($response,'<?xml');
$end=strrpos($response,'>');
$response_string=substr($response,$start,$end-$start+1);
return($response_string);
}
}
?>
तो फिर तुम इस
<?php
new MySoapClient($wsdl_url);
?>
हालांकि मुझे आपकी कोड शैली बिल्कुल पसंद नहीं है, फिर भी आप इस स्पष्ट कोड उदाहरण के साथ मेरे नायक हैं :) आकर्षण की तरह काम किया। हालांकि मुझे इसे एक लिट ट्विक करना पड़ा। मैं इसे एक नए जवाब में डाल दूंगा। – func0der
कर सकते हैं भले ही इस सवाल का जवाब यहाँ एक बहुत दिया गया है पहले से ही, मैं एक साथ डाल दिया है एक सामान्य समाधान यह बातें ध्यान में रखता है, कि XML आवरण के बिना आ सकता है।
class SoapClientExtended extends SoapClient
{
/**
* Sends SOAP request using a predefined XML
*
* Overwrites the default method SoapClient::__doRequest() to make it work
* with multipart responses.
*
* @param string $request The XML content to send
* @param string $location The URL to request.
* @param string $action The SOAP action. [optional] default=''
* @param int $version The SOAP version. [optional] default=1
* @param int $one_way [optional] (If one_way is set to 1, this method
* returns nothing. Use this where a response is
* not expected.)
*
* @return string The XML SOAP response.
*/
public function __doRequest(
$request, $location, $action, $version, $one_way = 0
) {
$result = parent::__doRequest($request, $location, $action, $version, $one_way);
$headers = $this->__getLastResponseHeaders();
// Do we have a multipart request?
if (preg_match('#^Content-Type:.*multipart\/.*#mi', $headers) !== 0) {
// Make all line breaks even.
$result = str_replace("\r\n", "\n", $result);
// Split between headers and content.
list(, $content) = preg_split("#\n\n#", $result);
// Split again for multipart boundary.
list($result,) = preg_split("#\n--#", $content);
}
return $result;
}
}
यह केवल काम करता है अगर आप विकल्प trace => true
साथ SoapClientExtended
आरंभ कर देगा।
कोड ने अभी भी "trace => true" विकल्प के साथ मेरे लिए काम किया है।
साझा करने के लिए धन्यवाद!
- 1. लेआउट एल्गोरिदम जो कंपास को समझता है
- 2. जावा: सरल SOAP क्लाइंट
- 3. सरल स्कैला SOAP क्लाइंट
- 4. एक साधारण जावा SOAP क्लाइंट
- 5. PHP SOAP फ़ाइलों को स्थानांतरित करना
- 6. PHP 5 SOAP क्लाइंट वापस लौटाता है जब WSDL- प्रदत्त फ़ंक्शन को
- 7. PHP घातक त्रुटि: "संदेश पर निर्दिष्ट SOAP क्रिया,", HTTP SOAP क्रिया से मेल नहीं खाती है "
- 8. SOAP UI का उपयोग करके SOAP के लिए क्लाइंट PHP कोड कैसे उत्पन्न करें?
- 9. PHP और SOAP। बदलें लिफाफा
- 10. PHP SOAP HTTP अनुरोध
- 11. PHP सोप क्लाइंट अनुरोध
- 12. PHP सोप क्लाइंट विकृत xml
- 13. सर्वर-साइड एप्लिकेशन से क्लाइंट को संदेशों को धक्का देना?
- 14. क्या PHP के SOAP एक्सटेंशन का कोई अच्छा विकल्प है?
- 15. SOAP- आधारित वेब सेवा क्यों नहीं है?
- 16. क्या कोई 3 रास्ता विलय उपकरण है जो सामान्य रिफैक्टरिंग को "समझता है"?
- 17. क्या स्रोत नियंत्रण के लिए कोई विलय उपकरण है जो कोड को समझता है?
- 18. PHP सोप क्लाइंट और एक जटिल शीर्षलेख
- 19. PHP: सबसे तेज़ SOAP, file_get_contents या कर्ल क्या है?
- 20. PHP में SSL प्रमाणपत्र के साथ SOAP अनुरोध कैसे भेजें?
- 21. साबुन: लिफाफा SOAP-ENV: लिफाफा PHP
- 22. HTTP/SOAP को "मोटी"
- 23. पायथन SOAP क्लाइंट - एसयूडीएस या कुछ और उपयोग करें?
- 24. विम में जावास्क्रिप्ट के लिए ऑटोइंडेंट जो सेमीकॉलन सम्मिलन को समझता है
- 25. आरईएसटी क्लाइंट जो oauth
- 26. क्या मैं जॉइन को गलत समझता हूं?
- 27. PHP चैट क्लाइंट
- 28. एएसपीनेट एमवीसी इसे कैसे समझता है?
- 29. PHP सोप क्लाइंट टाइमआउट
- 30. PHP स्ट्रेटोटाइम() फ़ंक्शन जो प्रारूप को स्वीकार करता है?
मुझे लगता है कि "__doRequest" होना चाहिए "_doRequest"। – understack