78 $imported_urls = array();
80 while ($imported > 0) {
83 foreach ($this->schemas as $ns => $list) {
84 foreach ($list as $xs) {
85 $wsdlparts = parse_url($this->
wsdl);
86 foreach ($xs->imports as $ns2 => $list2) {
87 for ($ii = 0; $ii < count($list2); $ii++) {
88 if (! $list2[$ii][
'loaded']) {
89 $this->schemas[$ns]->imports[$ns2][$ii][
'loaded'] =
true;
90 $url = $list2[$ii][
'location'];
92 $urlparts = parse_url($url);
93 if (!isset($urlparts[
'host'])) {
94 $url = $wsdlparts[
'scheme'] .
'://' . $wsdlparts[
'host'] . (isset($wsdlparts[
'port']) ?
':' .$wsdlparts[
'port'] :
'') .
95 substr($wsdlparts[
'path'],0,strrpos($wsdlparts[
'path'],
'/') + 1) .$urlparts[
'path'];
97 if (! in_array($url, $imported_urls)) {
100 $imported_urls[] = $url;
103 $this->
debug(
"Unexpected scenario: empty URL for unloaded import");
111 $wsdlparts = parse_url($this->
wsdl);
112 foreach ($this->
import as $ns => $list) {
113 for ($ii = 0; $ii < count($list); $ii++) {
114 if (! $list[$ii][
'loaded']) {
115 $this->
import[$ns][$ii][
'loaded'] =
true;
116 $url = $list[$ii][
'location'];
118 $urlparts = parse_url($url);
119 if (!isset($urlparts[
'host'])) {
120 $url = $wsdlparts[
'scheme'] .
'://' . $wsdlparts[
'host'] . (isset($wsdlparts[
'port']) ?
':' . $wsdlparts[
'port'] :
'') .
121 substr($wsdlparts[
'path'],0,strrpos($wsdlparts[
'path'],
'/') + 1) .$urlparts[
'path'];
123 if (! in_array($url, $imported_urls)) {
126 $imported_urls[] = $url;
129 $this->
debug(
"Unexpected scenario: empty URL for unloaded import");
136 foreach($this->bindings as $binding => $bindingData) {
137 if (isset($bindingData[
'operations']) && is_array($bindingData[
'operations'])) {
138 foreach($bindingData[
'operations'] as $operation =>
$data) {
139 $this->
debug(
'post-parse data gathering for ' . $operation);
140 $this->bindings[$binding][
'operations'][$operation][
'input'] =
141 isset($this->bindings[$binding][
'operations'][$operation][
'input']) ?
142 array_merge($this->bindings[$binding][
'operations'][$operation][
'input'], $this->portTypes[ $bindingData[
'portType'] ][$operation][
'input']) :
143 $this->portTypes[ $bindingData[
'portType'] ][$operation][
'input'];
144 $this->bindings[$binding][
'operations'][$operation][
'output'] =
145 isset($this->bindings[$binding][
'operations'][$operation][
'output']) ?
146 array_merge($this->bindings[$binding][
'operations'][$operation][
'output'], $this->portTypes[ $bindingData[
'portType'] ][$operation][
'output']) :
147 $this->portTypes[ $bindingData[
'portType'] ][$operation][
'output'];
148 if(isset($this->messages[ $this->bindings[$binding][
'operations'][$operation][
'input'][
'message'] ])){
149 $this->bindings[$binding][
'operations'][$operation][
'input'][
'parts'] = $this->messages[ $this->bindings[$binding][
'operations'][$operation][
'input'][
'message'] ];
151 if(isset($this->messages[ $this->bindings[$binding][
'operations'][$operation][
'output'][
'message'] ])){
152 $this->bindings[$binding][
'operations'][$operation][
'output'][
'parts'] = $this->messages[ $this->bindings[$binding][
'operations'][$operation][
'output'][
'message'] ];
154 if (isset($bindingData[
'style'])) {
155 $this->bindings[$binding][
'operations'][$operation][
'style'] = $bindingData[
'style'];
157 $this->bindings[$binding][
'operations'][$operation][
'transport'] = isset($bindingData[
'transport']) ? $bindingData[
'transport'] :
'';
158 $this->bindings[$binding][
'operations'][$operation][
'documentation'] = isset($this->portTypes[ $bindingData[
'portType'] ][$operation][
'documentation']) ? $this->portTypes[ $bindingData[
'portType'] ][$operation][
'documentation'] :
'';
159 $this->bindings[$binding][
'operations'][$operation][
'endpoint'] = isset($bindingData[
'endpoint']) ? $bindingData[
'endpoint'] :
'';
174 $this->
debug(
'no wsdl passed to parseWSDL()!!');
175 $this->
setError(
'no wsdl passed to parseWSDL()!!');
180 $wsdl_props = parse_url(
$wsdl);
182 if (isset($wsdl_props[
'scheme']) && ($wsdl_props[
'scheme'] ==
'http' || $wsdl_props[
'scheme'] ==
'https')) {
183 $this->
debug(
'getting WSDL http(s) URL ' .
$wsdl);
186 $tr->request_method =
'GET';
187 $tr->useSOAPAction =
false;
188 if($this->proxyhost && $this->proxyport){
189 $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
191 $tr->setEncoding(
'gzip, deflate');
192 $wsdl_string = $tr->send(
'', $this->timeout, $this->response_timeout);
197 if($err = $tr->getError() ){
198 $errstr =
'HTTP ERROR: '.$err;
199 $this->
debug($errstr);
205 $this->
debug(
"got WSDL URL");
208 if (isset($wsdl_props[
'scheme']) && ($wsdl_props[
'scheme'] ==
'file') && isset($wsdl_props[
'path'])) {
209 $path = isset($wsdl_props[
'host']) ? ($wsdl_props[
'host'] .
':' . $wsdl_props[
'path']) : $wsdl_props[
'path'];
213 $this->
debug(
'getting WSDL file ' . $path);
214 if ($fp = @fopen($path,
'r')) {
216 while (
$data = fread($fp, 32768)) {
217 $wsdl_string .=
$data;
221 $errstr =
"Bad path to WSDL file $path";
222 $this->
debug($errstr);
227 $this->
debug(
'Parse WSDL');
230 $this->parser = xml_parser_create();
233 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
235 xml_set_object($this->parser, $this);
237 xml_set_element_handler($this->parser,
'start_element',
'end_element');
238 xml_set_character_data_handler($this->parser,
'character_data');
240 if (!xml_parse($this->parser, $wsdl_string,
true)) {
243 'XML error parsing WSDL from %s on line %d: %s',
245 xml_get_current_line_number($this->parser),
246 xml_error_string(xml_get_error_code($this->parser))
248 $this->
debug($errstr);
249 $this->
debug(
"XML payload:\n" . $wsdl_string);
254 xml_parser_free($this->parser);
255 $this->
debug(
'Parsing WSDL done');
273 if ($this->status ==
'schema') {
274 $this->currentSchema->schemaStartElement(
$parser, $name, $attrs);
275 $this->
appendDebug($this->currentSchema->getDebug());
276 $this->currentSchema->clearDebug();
277 } elseif (ereg(
'schema$', $name)) {
278 $this->
debug(
'Parsing WSDL schema');
280 $this->status =
'schema';
281 $this->currentSchema =
new xmlschema(
'',
'', $this->namespaces);
282 $this->currentSchema->schemaStartElement(
$parser, $name, $attrs);
283 $this->
appendDebug($this->currentSchema->getDebug());
284 $this->currentSchema->clearDebug();
287 $pos = $this->position++;
290 $this->depth_array[
$depth] = $pos;
291 $this->message[$pos] = array(
'cdata' =>
'');
293 if (count($attrs) > 0) {
295 foreach($attrs as $k => $v) {
296 if (ereg(
"^xmlns", $k)) {
297 if ($ns_prefix = substr(strrchr($k,
':'), 1)) {
298 $this->namespaces[$ns_prefix] = $v;
300 $this->namespaces[
'ns' . (count($this->namespaces) + 1)] = $v;
302 if ($v ==
'http://www.w3.org/2001/XMLSchema' || $v ==
'http://www.w3.org/1999/XMLSchema' || $v ==
'http://www.w3.org/2000/10/XMLSchema') {
303 $this->XMLSchemaVersion = $v;
304 $this->namespaces[
'xsi'] = $v .
'-instance';
309 foreach($attrs as $k => $v) {
310 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
311 if ($k !=
'location' && $k !=
'soapAction' && $k !=
'namespace') {
312 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
321 if (ereg(
':', $name)) {
323 $prefix = substr($name, 0, strpos($name,
':'));
325 $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] :
'';
327 $name = substr(strstr($name,
':'), 1);
331 switch ($this->status) {
333 if ($name ==
'part') {
334 if (isset($attrs[
'type'])) {
335 $this->
debug(
"msg " . $this->currentMessage .
": found part $attrs[name]: " . implode(
',', $attrs));
338 if (isset($attrs[
'element'])) {
339 $this->
debug(
"msg " . $this->currentMessage .
": found part $attrs[name]: " . implode(
',', $attrs));
347 $this->currentPortOperation = $attrs[
'name'];
348 $this->
debug(
"portType $this->currentPortType operation: $this->currentPortOperation");
349 if (isset($attrs[
'parameterOrder'])) {
353 case 'documentation':
354 $this->documentation =
true;
358 $m = isset($attrs[
'message']) ? $this->
getLocalPart($attrs[
'message']) :
'';
367 if (isset($attrs[
'style'])) {
370 $this->bindings[
$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
376 if (isset($attrs[
'soapAction'])) {
379 if (isset($attrs[
'style'])) {
382 if (isset($attrs[
'name'])) {
383 $this->currentOperation = $attrs[
'name'];
384 $this->
debug(
"current binding operation: $this->currentOperation");
391 $this->opStatus =
'input';
394 $this->opStatus =
'output';
397 if (isset($this->bindings[$this->currentBinding][
'operations'][$this->currentOperation][$this->opStatus])) {
408 $this->currentPort = $attrs[
'name'];
409 $this->
debug(
'current port: ' . $this->currentPort);
417 $this->bindings[ $this->ports[
$this->currentPort][
'binding'] ][
'endpoint'] = $attrs[
'location'];
425 if (isset($attrs[
'location'])) {
426 $this->
import[$attrs[
'namespace']][] = array(
'location' => $attrs[
'location'],
'loaded' =>
false);
427 $this->
debug(
'parsing import ' . $attrs[
'namespace'].
' - ' . $attrs[
'location'] .
' (' . count($this->
import[$attrs[
'namespace']]).
')');
429 $this->
import[$attrs[
'namespace']][] = array(
'location' =>
'',
'loaded' =>
true);
431 $this->namespaces[
'ns'.(count($this->namespaces)+1)] = $attrs[
'namespace'];
433 $this->
debug(
'parsing import ' . $attrs[
'namespace'].
' - [no location] (' . count($this->
import[$attrs[
'namespace']]).
')');
441 $this->status =
'message';
442 $this->messages[$attrs[
'name']] = array();
443 $this->currentMessage = $attrs[
'name'];
446 $this->status =
'portType';
447 $this->portTypes[$attrs[
'name']] = array();
448 $this->currentPortType = $attrs[
'name'];
451 if (isset($attrs[
'name'])) {
453 if (strpos($attrs[
'name'],
':')) {
454 $this->currentBinding = $this->
getLocalPart($attrs[
'name']);
456 $this->currentBinding = $attrs[
'name'];
458 $this->status =
'binding';
460 $this->
debug(
"current binding: $this->currentBinding of portType: " . $attrs[
'type']);
464 $this->serviceName = $attrs[
'name'];
465 $this->status =
'service';
466 $this->
debug(
'current service: ' . $this->serviceName);
469 foreach ($attrs as $name => $value) {
470 $this->wsdl_info[$name] = $value;
486 if ( ereg(
'schema$', $name)) {
488 $this->
appendDebug($this->currentSchema->getDebug());
489 $this->currentSchema->clearDebug();
491 $this->
debug(
'Parsing WSDL schema done');
493 if ($this->status ==
'schema') {
494 $this->currentSchema->schemaEndElement(
$parser, $name);
500 if ($this->documentation) {
503 $this->documentation =
false;
516 $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[
$this->depth] : 0;
517 if (isset($this->message[$pos][
'cdata'])) {
518 $this->message[$pos][
'cdata'] .=
$data;
520 if ($this->documentation) {
521 $this->documentation .=
$data;
527 if (is_array($this->bindings[$binding])) {
528 return $this->bindings[$binding];
542 if ($bindingType ==
'soap') {
543 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap/';
546 foreach($this->ports as $port => $portData) {
548 if ($portData[
'bindingType'] == $bindingType) {
553 if (isset($this->bindings[ $portData[
'binding'] ][
'operations'])) {
554 $ops = array_merge ($ops, $this->bindings[ $portData[
'binding'] ][
'operations']);
571 if ($bindingType ==
'soap') {
572 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap/';
575 foreach($this->ports as $port => $portData) {
577 if ($portData[
'bindingType'] == $bindingType) {
580 foreach(array_keys($this->bindings[ $portData[
'binding'] ][
'operations']) as $bOperation) {
582 if ($operation == $bOperation) {
583 $opData = $this->bindings[ $portData[
'binding'] ][
'operations'][$operation];
600 if ($bindingType ==
'soap') {
601 $bindingType =
'http://schemas.xmlsoap.org/wsdl/soap/';
604 foreach($this->ports as $port => $portData) {
606 if ($portData[
'bindingType'] == $bindingType) {
608 foreach ($this->bindings[ $portData[
'binding'] ][
'operations'] as $bOperation =>
$opData) {
609 if (
$opData[
'soapAction'] == $soapAction) {
636 $this->
debug(
"in getTypeDef: type=$type, ns=$ns");
637 if ((! $ns) && isset($this->namespaces[
'tns'])) {
638 $ns = $this->namespaces[
'tns'];
639 $this->
debug(
"in getTypeDef: type namespace forced to $ns");
641 if (isset($this->schemas[$ns])) {
642 $this->
debug(
"in getTypeDef: have schema for namespace $ns");
643 for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
644 $xs = &$this->schemas[$ns][$i];
645 $t = $xs->getTypeDef($type);
649 if (!isset(
$t[
'phpType'])) {
651 $uqType = substr(
$t[
'type'], strrpos(
$t[
'type'],
':') + 1);
652 $ns = substr(
$t[
'type'], 0, strrpos(
$t[
'type'],
':'));
655 $this->
debug(
"found type for [element] $type:");
657 if (isset($etype[
'phpType'])) {
658 $t[
'phpType'] = $etype[
'phpType'];
660 if (isset($etype[
'elements'])) {
661 $t[
'elements'] = $etype[
'elements'];
663 if (isset($etype[
'attrs'])) {
664 $t[
'attrs'] = $etype[
'attrs'];
672 $this->
debug(
"in getTypeDef: do not have schema for namespace $ns");
683 global $HTTP_SERVER_VARS;
685 if (isset($_SERVER)) {
686 $PHP_SELF = $_SERVER[
'PHP_SELF'];
687 } elseif (isset($HTTP_SERVER_VARS)) {
688 $PHP_SELF = $HTTP_SERVER_VARS[
'PHP_SELF'];
690 $this->
setError(
"Neither _SERVER nor HTTP_SERVER_VARS is available");
694 <html><head><title>NuSOAP: '.$this->serviceName.
'</title>
695 <style type="text/css">
696 body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
697 p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
698 pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
699 ul { margin-top: 10px; margin-left: 20px; }
700 li { list-style-type: none; margin-top: 10px; color: #000000; }
702 margin-left: 0px; padding-bottom: 2em; }
704 padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
705 margin-top: 10px; margin-left: 0px; color: #000000;
706 background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
708 font-family: arial; font-size: 26px; color: #ffffff;
709 background-color: #999999; width: 105%; margin-left: 0px;
710 padding-top: 10px; padding-bottom: 10px; padding-left: 15px;}
712 position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
713 font-family: arial; overflow: hidden; width: 600;
714 padding: 20px; font-size: 10px; background-color: #999999;
715 layer-background-color:#FFFFFF; }
716 a,a:active { color: charcoal; font-weight: bold; }
717 a:visited { color: #666666; font-weight: bold; }
718 a:hover { color: cc3300; font-weight: bold; }
720 <script language="JavaScript" type="text/javascript">
722 // POP-UP CAPTIONS...
723 function lib_bwcheck(){ //Browsercheck (needed)
724 this.ver=navigator.appVersion
725 this.agent=navigator.userAgent
726 this.dom=document.getElementById?1:0
727 this.opera5=this.agent.indexOf("Opera 5")>-1
728 this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
729 this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
730 this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
731 this.ie=this.ie4||this.ie5||this.ie6
732 this.mac=this.agent.indexOf("Mac")>-1
733 this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
734 this.ns4=(document.layers && !this.dom)?1:0;
735 this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
738 var bw = new lib_bwcheck()
739 //Makes crossbrowser object.
740 function makeObj(obj){
741 this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
742 if(!this.evnt) return false
743 this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
744 this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
745 this.writeIt=b_writeIt;
748 // A unit of measure that will be added when setting the position of a layer.
749 //var px = bw.ns4||window.opera?"":"px";
750 function b_writeIt(text){
751 if (bw.ns4){this.wref.write(text);this.wref.close()}
752 else this.wref.innerHTML = text
756 function popup(divid){
757 if(oDesc = new makeObj(divid)){
758 oDesc.css.visibility = "visible"
761 function popout(){ // Hides message
762 if(oDesc) oDesc.css.visibility = "hidden"
770 <div class=title>'.$this->serviceName.
'</div>
772 <p>View the <a href="'.$PHP_SELF.
'?wsdl">WSDL</a> for the service.
773 Click on an operation name to view it's details.</p>
776 $b .=
"<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
778 $b .=
"<div id='$op' class='hidden'>
779 <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
780 foreach(
$data as $donnie => $marie){
781 if($donnie ==
'input' || $donnie ==
'output'){
782 $b .=
"<font color='white'>".ucfirst($donnie).
':</font><br>';
783 foreach($marie as $captain => $tenille){
784 if($captain ==
'parts'){
785 $b .=
" $captain:<br>";
787 foreach($tenille as $joanie => $chachi){
788 $b .=
" $joanie: $chachi<br>";
792 $b .=
" $captain: $tenille<br>";
796 $b .=
"<font color='white'>".ucfirst($donnie).
":</font> $marie<br>";
804 </div></body></html>';
817 $xml =
'<?xml version="1.0" encoding="ISO-8859-1"?>';
818 $xml .=
"\n<definitions";
819 foreach($this->namespaces as $k => $v) {
820 $xml .=
" xmlns:$k=\"$v\"";
823 if (isset($this->namespaces[
'wsdl'])) {
824 $xml .=
" xmlns=\"" . $this->namespaces[
'wsdl'] .
"\"";
826 if (isset($this->namespaces[
'tns'])) {
827 $xml .=
" targetNamespace=\"" . $this->namespaces[
'tns'] .
"\"";
831 if (
sizeof($this->
import) > 0) {
832 foreach($this->
import as $ns => $list) {
833 foreach ($list as $ii) {
834 if ($ii[
'location'] !=
'') {
835 $xml .=
'<import location="' . $ii[
'location'] .
'" namespace="' . $ns .
'" />';
837 $xml .=
'<import namespace="' . $ns .
'" />';
843 if (count($this->schemas)>=1) {
845 foreach ($this->schemas as $ns => $list) {
846 foreach ($list as $xs) {
847 $xml .= $xs->serializeSchema();
853 if (count($this->messages) >= 1) {
854 foreach($this->messages as $msgName => $msgParts) {
855 $xml .=
"\n<message name=\"" . $msgName .
'">';
856 if(is_array($msgParts)){
857 foreach($msgParts as $partName => $partType) {
859 if (strpos($partType,
':')) {
861 } elseif (isset($this->typemap[$this->namespaces[
'xsd']][$partType])) {
865 foreach($this->typemap as $ns => $types) {
866 if (isset($types[$partType])) {
870 if (!isset($typePrefix)) {
871 die(
"$partType has no namespace!");
876 if ($typeDef[
'typeClass'] ==
'element') {
877 $elementortype =
'element';
879 $elementortype =
'type';
881 $xml .=
'<part name="' . $partName .
'" ' . $elementortype .
'="' . $typePrefix .
':' . $this->
getLocalPart($partType) .
'" />';
884 $xml .=
'</message>';
888 if (count($this->bindings) >= 1) {
891 foreach($this->bindings as $bindingName => $attrs) {
892 $binding_xml .=
"\n<binding name=\"" . $bindingName .
'" type="tns:' . $attrs[
'portType'] .
'">';
893 $binding_xml .=
'<soap:binding style="' . $attrs[
'style'] .
'" transport="' . $attrs[
'transport'] .
'"/>';
894 $portType_xml .=
"\n<portType name=\"" . $attrs[
'portType'] .
'">';
895 foreach($attrs[
'operations'] as $opName => $opParts) {
896 $binding_xml .=
'<operation name="' . $opName .
'">';
897 $binding_xml .=
'<soap:operation soapAction="' . $opParts[
'soapAction'] .
'" style="'. $opParts[
'style'] .
'"/>';
898 if (isset($opParts[
'input'][
'encodingStyle']) && $opParts[
'input'][
'encodingStyle'] !=
'') {
899 $enc_style =
' encodingStyle="' . $opParts[
'input'][
'encodingStyle'] .
'"';
903 $binding_xml .=
'<input><soap:body use="' . $opParts[
'input'][
'use'] .
'" namespace="' . $opParts[
'input'][
'namespace'] .
'"' . $enc_style .
'/></input>';
904 if (isset($opParts[
'output'][
'encodingStyle']) && $opParts[
'output'][
'encodingStyle'] !=
'') {
905 $enc_style =
' encodingStyle="' . $opParts[
'output'][
'encodingStyle'] .
'"';
909 $binding_xml .=
'<output><soap:body use="' . $opParts[
'output'][
'use'] .
'" namespace="' . $opParts[
'output'][
'namespace'] .
'"' . $enc_style .
'/></output>';
910 $binding_xml .=
'</operation>';
911 $portType_xml .=
'<operation name="' . $opParts[
'name'] .
'"';
912 if (isset($opParts[
'parameterOrder'])) {
913 $portType_xml .=
' parameterOrder="' . $opParts[
'parameterOrder'] .
'"';
915 $portType_xml .=
'>';
916 if(isset($opParts[
'documentation']) && $opParts[
'documentation'] !=
'') {
917 $portType_xml .=
'<documentation>' . htmlspecialchars($opParts[
'documentation']) .
'</documentation>';
919 $portType_xml .=
'<input message="tns:' . $opParts[
'input'][
'message'] .
'"/>';
920 $portType_xml .=
'<output message="tns:' . $opParts[
'output'][
'message'] .
'"/>';
921 $portType_xml .=
'</operation>';
923 $portType_xml .=
'</portType>';
924 $binding_xml .=
'</binding>';
926 $xml .= $portType_xml . $binding_xml;
929 $xml .=
"\n<service name=\"" . $this->serviceName .
'">';
930 if (count($this->ports) >= 1) {
931 foreach($this->ports as $pName => $attrs) {
932 $xml .=
'<port name="' . $pName .
'" binding="tns:' . $attrs[
'binding'] .
'">';
933 $xml .=
'<soap:address location="' . $attrs[
'location'] . ($debug ?
'?debug=1' :
'') .
'"/>';
937 $xml .=
'</service>';
938 return $xml .
"\n</definitions>";
956 $this->
debug(
"in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
959 if ($direction !=
'input' && $direction !=
'output') {
960 $this->
debug(
'The value of the \$direction argument needs to be either "input" or "output"');
961 $this->
setError(
'The value of the \$direction argument needs to be either "input" or "output"');
965 $this->
debug(
'Unable to retrieve WSDL data for operation: ' . $operation);
966 $this->
setError(
'Unable to retrieve WSDL data for operation: ' . $operation);
969 $this->
debug(
'opData:');
973 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
974 if(($direction ==
'input') && isset(
$opData[
'output'][
'encodingStyle']) && (
$opData[
'output'][
'encodingStyle'] != $encodingStyle)) {
975 $encodingStyle =
$opData[
'output'][
'encodingStyle'];
976 $enc_style = $encodingStyle;
981 if (isset(
$opData[$direction][
'parts']) &&
sizeof(
$opData[$direction][
'parts']) > 0) {
983 $use =
$opData[$direction][
'use'];
984 $this->
debug(
'have ' . count(
$opData[$direction][
'parts']) .
' part(s) to serialize');
985 if (is_array($parameters)) {
987 $this->
debug(
'have ' . count($parameters) .
' parameter(s) provided as ' . $parametersArrayType .
' to serialize');
988 foreach(
$opData[$direction][
'parts'] as $name => $type) {
989 $this->
debug(
'serializing part "'.$name.
'" of type "'.$type.
'"');
991 if (isset(
$opData[$direction][
'encodingStyle']) && $encodingStyle !=
$opData[$direction][
'encodingStyle']) {
992 $encodingStyle =
$opData[$direction][
'encodingStyle'];
993 $enc_style = $encodingStyle;
999 if ($parametersArrayType ==
'arraySimple') {
1000 $p = array_shift($parameters);
1001 $this->
debug(
'calling serializeType w/indexed param');
1002 $xml .= $this->
serializeType($name, $type, $p, $use, $enc_style);
1003 } elseif (isset($parameters[$name])) {
1004 $this->
debug(
'calling serializeType w/named param');
1005 $xml .= $this->
serializeType($name, $type, $parameters[$name], $use, $enc_style);
1008 $this->
debug(
'calling serializeType w/null param');
1009 $xml .= $this->
serializeType($name, $type, null, $use, $enc_style);
1013 $this->
debug(
'no parameters passed.');
1016 $this->
debug(
"serializeRPCParameters returning: $xml");
1035 $this->
debug(
"in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1038 if ($direction !=
'input' && $direction !=
'output') {
1039 $this->
debug(
'The value of the \$direction argument needs to be either "input" or "output"');
1040 $this->
setError(
'The value of the \$direction argument needs to be either "input" or "output"');
1044 $this->
debug(
'Unable to retrieve WSDL data for operation: ' . $operation);
1045 $this->
setError(
'Unable to retrieve WSDL data for operation: ' . $operation);
1048 $this->
debug(
'opData:');
1052 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
1053 if(($direction ==
'input') && isset(
$opData[
'output'][
'encodingStyle']) && (
$opData[
'output'][
'encodingStyle'] != $encodingStyle)) {
1054 $encodingStyle =
$opData[
'output'][
'encodingStyle'];
1055 $enc_style = $encodingStyle;
1060 if (isset(
$opData[$direction][
'parts']) &&
sizeof(
$opData[$direction][
'parts']) > 0) {
1062 $use =
$opData[$direction][
'use'];
1063 $this->
debug(
"use=$use");
1064 $this->
debug(
'got ' . count(
$opData[$direction][
'parts']) .
' part(s)');
1065 if (is_array($parameters)) {
1067 $this->
debug(
'have ' . $parametersArrayType .
' parameters');
1068 foreach(
$opData[$direction][
'parts'] as $name => $type) {
1069 $this->
debug(
'serializing part "'.$name.
'" of type "'.$type.
'"');
1071 if(isset(
$opData[$direction][
'encodingStyle']) && $encodingStyle !=
$opData[$direction][
'encodingStyle']) {
1072 $encodingStyle =
$opData[$direction][
'encodingStyle'];
1073 $enc_style = $encodingStyle;
1079 if ($parametersArrayType ==
'arraySimple') {
1080 $p = array_shift($parameters);
1081 $this->
debug(
'calling serializeType w/indexed param');
1082 $xml .= $this->
serializeType($name, $type, $p, $use, $enc_style);
1083 } elseif (isset($parameters[$name])) {
1084 $this->
debug(
'calling serializeType w/named param');
1085 $xml .= $this->
serializeType($name, $type, $parameters[$name], $use, $enc_style);
1088 $this->
debug(
'calling serializeType w/null param');
1089 $xml .= $this->
serializeType($name, $type, null, $use, $enc_style);
1093 $this->
debug(
'no parameters passed.');
1096 $this->
debug(
"serializeParameters returning: $xml");
1112 function serializeType($name, $type, $value, $use=
'encoded', $encodingStyle=
false, $unqualified=
false)
1114 $this->
debug(
"in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ?
"unqualified" :
"qualified"));
1116 if($use ==
'encoded' && $encodingStyle) {
1117 $encodingStyle =
' SOAP-ENV:encodingStyle="' . $encodingStyle .
'"';
1121 if (is_object($value) && get_class($value) ==
'soapval') {
1122 if ($value->type_ns) {
1123 $type = $value->type_ns .
':' . $value->type;
1125 $this->
debug(
"in serializeType: soapval overrides type to $type");
1126 } elseif ($value->type) {
1127 $type = $value->type;
1129 $this->
debug(
"in serializeType: soapval overrides type to $type");
1132 $this->
debug(
"in serializeType: soapval does not override type");
1134 $attrs = $value->attributes;
1135 $value = $value->value;
1136 $this->
debug(
"in serializeType: soapval overrides value to $value");
1138 if (!is_array($value)) {
1139 $value[
'!'] = $value;
1141 foreach ($attrs as
$n => $v) {
1142 $value[
'!' .
$n] = $v;
1144 $this->
debug(
"in serializeType: soapval provides attributes");
1151 if (strpos($type,
':')) {
1152 $uqType = substr($type, strrpos($type,
':') + 1);
1153 $ns = substr($type, 0, strrpos($type,
':'));
1154 $this->
debug(
"in serializeType: got a prefixed type: $uqType, $ns");
1157 $this->
debug(
"in serializeType: expanded prefixed type: $uqType, $ns");
1160 if($ns == $this->XMLSchemaVersion || $ns ==
'http://schemas.xmlsoap.org/soap/encoding/'){
1161 $this->
debug(
'in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1162 if ($unqualified && $use ==
'literal') {
1163 $elementNS =
" xmlns=\"\"";
1167 if (is_null($value)) {
1168 if ($use ==
'literal') {
1170 $xml =
"<$name$elementNS/>";
1173 $xml =
"<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"/>";
1175 $this->
debug(
"in serializeType: returning: $xml");
1178 if ($uqType ==
'boolean') {
1179 if ((is_string($value) && $value ==
'false') || (! $value)) {
1185 if ($uqType ==
'string' && gettype($value) ==
'string') {
1188 if (($uqType ==
'long' || $uqType ==
'unsignedLong') && gettype($value) ==
'double') {
1189 $value = sprintf(
"%.0lf", $value);
1195 if ($use ==
'literal') {
1197 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\">$value</$name>";
1199 $xml =
"<$name$elementNS>$value</$name>";
1202 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"$encodingStyle>$value</$name>";
1204 $this->
debug(
"in serializeType: returning: $xml");
1207 $this->
debug(
'custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1208 }
else if ($ns ==
'http://xml.apache.org/xml-soap') {
1209 $this->
debug(
'in serializeType: appears to be Apache SOAP type');
1210 if ($uqType ==
'Map') {
1213 $this->
debug(
'in serializeType: Add namespace for Apache SOAP type');
1214 $tt_prefix =
'ns' . rand(1000, 9999);
1215 $this->namespaces[$tt_prefix] =
'http://xml.apache.org/xml-soap';
1220 foreach($value as $k => $v) {
1221 $this->
debug(
"serializing map element: key $k, value $v");
1222 $contents .=
'<item>';
1223 $contents .= $this->
serialize_val($k,
'key',
false,
false,
false,
false,$use);
1224 $contents .= $this->
serialize_val($v,
'value',
false,
false,
false,
false,$use);
1225 $contents .=
'</item>';
1227 if ($use ==
'literal') {
1229 $xml =
"<$name xsi:type=\"" . $tt_prefix .
":$uqType\">$contents</$name>";
1231 $xml =
"<$name>$contents</$name>";
1234 $xml =
"<$name xsi:type=\"" . $tt_prefix .
":$uqType\"$encodingStyle>$contents</$name>";
1236 $this->
debug(
"in serializeType: returning: $xml");
1239 $this->
debug(
'in serializeType: Apache SOAP type, but only support Map');
1244 $this->
debug(
"in serializeType: No namespace for type $type");
1248 if(!$typeDef = $this->
getTypeDef($uqType, $ns)){
1249 $this->
setError(
"$type ($uqType) is not a supported type.");
1250 $this->
debug(
"in serializeType: $type ($uqType) is not a supported type.");
1253 $this->
debug(
"in serializeType: found typeDef");
1256 $phpType = $typeDef[
'phpType'];
1257 $this->
debug(
"in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef[
'arrayType']) ? $typeDef[
'arrayType'] :
'') );
1259 if ($phpType ==
'struct') {
1260 if (isset($typeDef[
'typeClass']) && $typeDef[
'typeClass'] ==
'element') {
1261 $elementName = $uqType;
1262 if (isset($typeDef[
'form']) && ($typeDef[
'form'] ==
'qualified')) {
1263 $elementNS =
" xmlns=\"$ns\"";
1265 $elementNS =
" xmlns=\"\"";
1268 $elementName = $name;
1270 $elementNS =
" xmlns=\"\"";
1275 if (is_null($value)) {
1276 if ($use ==
'literal') {
1278 $xml =
"<$elementName$elementNS/>";
1280 $xml =
"<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"/>";
1282 $this->
debug(
"in serializeType: returning: $xml");
1285 if (is_object($value)) {
1286 $value = get_object_vars($value);
1288 if (is_array($value)) {
1290 if ($use ==
'literal') {
1292 $xml =
"<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\">";
1294 $xml =
"<$elementName$elementNS$elementAttrs>";
1297 $xml =
"<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"$encodingStyle>";
1301 $xml .=
"</$elementName>";
1303 $this->
debug(
"in serializeType: phpType is struct, but value is not an array");
1304 $this->
setError(
"phpType is struct, but value is not an array: see debug output for details");
1307 } elseif ($phpType ==
'array') {
1308 if (isset($typeDef[
'form']) && ($typeDef[
'form'] ==
'qualified')) {
1309 $elementNS =
" xmlns=\"$ns\"";
1312 $elementNS =
" xmlns=\"\"";
1317 if (is_null($value)) {
1318 if ($use ==
'literal') {
1320 $xml =
"<$name$elementNS/>";
1322 $xml =
"<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1331 $this->
debug(
"in serializeType: returning: $xml");
1334 if (isset($typeDef[
'multidimensional'])) {
1336 foreach($value as $v) {
1337 $cols =
',' .
sizeof($v);
1338 $nv = array_merge($nv, $v);
1344 if (is_array($value) &&
sizeof($value) >= 1) {
1345 $rows =
sizeof($value);
1347 foreach($value as $k => $v) {
1348 $this->
debug(
"serializing array element: $k, $v of type: $typeDef[arrayType]");
1350 if (!in_array($typeDef[
'arrayType'],$this->typemap[
'http://www.w3.org/2001/XMLSchema'])) {
1351 $contents .= $this->
serializeType(
'item', $typeDef[
'arrayType'], $v, $use);
1353 $contents .= $this->
serialize_val($v,
'item', $typeDef[
'arrayType'], null, $this->XMLSchemaVersion,
false, $use);
1362 if ($use ==
'literal') {
1363 $xml =
"<$name$elementNS>"
1367 $xml =
"<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace(
'http://schemas.xmlsoap.org/soap/encoding/').
':Array" '.
1370 .$this->getPrefixFromNamespace($this->
getPrefix($typeDef[
'arrayType']))
1371 .
":".$this->
getLocalPart($typeDef[
'arrayType']).
"[$rows$cols]\">"
1375 } elseif ($phpType ==
'scalar') {
1376 if (isset($typeDef[
'form']) && ($typeDef[
'form'] ==
'qualified')) {
1377 $elementNS =
" xmlns=\"$ns\"";
1380 $elementNS =
" xmlns=\"\"";
1385 if ($use ==
'literal') {
1387 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\">$value</$name>";
1389 $xml =
"<$name$elementNS>$value</$name>";
1392 $xml =
"<$name$elementNS xsi:type=\"" . $this->
getPrefixFromNamespace($ns) .
":$uqType\"$encodingStyle>$value</$name>";
1395 $this->
debug(
"in serializeType: returning: $xml");
1411 if (isset($typeDef[
'attrs']) && is_array($typeDef[
'attrs'])) {
1412 $this->
debug(
"serialize attributes for XML Schema type $ns:$uqType");
1413 if (is_array($value)) {
1415 } elseif (is_object($value)) {
1416 $xvalue = get_object_vars($value);
1418 $this->
debug(
"value is neither an array nor an object for XML Schema type $ns:$uqType");
1421 foreach ($typeDef[
'attrs'] as $aName => $attrs) {
1422 if (isset($xvalue[
'!' . $aName])) {
1423 $xname =
'!' . $aName;
1424 $this->
debug(
"value provided for attribute $aName with key $xname");
1425 } elseif (isset($xvalue[$aName])) {
1427 $this->
debug(
"value provided for attribute $aName with key $xname");
1428 } elseif (isset($attrs[
'default'])) {
1429 $xname =
'!' . $aName;
1430 $xvalue[$xname] = $attrs[
'default'];
1431 $this->
debug(
'use default value of ' . $xvalue[$aName] .
' for attribute ' . $aName);
1434 $this->
debug(
"no value provided for attribute $aName");
1437 $xml .=
" $aName=\"" . $this->
expandEntities($xvalue[$xname]) .
"\"";
1441 $this->
debug(
"no attributes to serialize for XML Schema type $ns:$uqType");
1443 if (isset($typeDef[
'extensionBase'])) {
1444 $ns = $this->
getPrefix($typeDef[
'extensionBase']);
1445 $uqType = $this->
getLocalPart($typeDef[
'extensionBase']);
1449 if ($typeDef = $this->
getTypeDef($uqType, $ns)) {
1450 $this->
debug(
"serialize attributes for extension base $ns:$uqType");
1453 $this->
debug(
"extension base $ns:$uqType is not a supported type");
1473 if (isset($typeDef[
'elements']) && is_array($typeDef[
'elements'])) {
1474 $this->
debug(
"in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1475 if (is_array($value)) {
1477 } elseif (is_object($value)) {
1478 $xvalue = get_object_vars($value);
1480 $this->
debug(
"value is neither an array nor an object for XML Schema type $ns:$uqType");
1484 if (count($typeDef[
'elements']) != count($xvalue)){
1487 foreach ($typeDef[
'elements'] as $eName => $attrs) {
1488 if (!isset($xvalue[$eName])) {
1489 if (isset($attrs[
'default'])) {
1490 $xvalue[$eName] = $attrs[
'default'];
1491 $this->
debug(
'use default value of ' . $xvalue[$eName] .
' for element ' . $eName);
1495 if (isset($optionals)
1496 && (!isset($xvalue[$eName]))
1497 && ( (!isset($attrs[
'nillable'])) || $attrs[
'nillable'] !=
'true')
1499 if (isset($attrs[
'minOccurs']) && $attrs[
'minOccurs'] <>
'0') {
1500 $this->
debug(
"apparent error: no value provided for element $eName with minOccurs=" . $attrs[
'minOccurs']);
1503 $this->
debug(
"no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1506 if (isset($xvalue[$eName])) {
1507 $v = $xvalue[$eName];
1511 if (isset($attrs[
'form'])) {
1512 $unqualified = ($attrs[
'form'] ==
'unqualified');
1514 $unqualified =
false;
1516 if (isset($attrs[
'maxOccurs']) && ($attrs[
'maxOccurs'] ==
'unbounded' || $attrs[
'maxOccurs'] > 1) && isset($v) && is_array($v) && $this->
isArraySimpleOrStruct($v) ==
'arraySimple') {
1518 foreach ($vv as $k => $v) {
1519 if (isset($attrs[
'type']) || isset($attrs[
'ref'])) {
1521 $xml .= $this->
serializeType($eName, isset($attrs[
'type']) ? $attrs[
'type'] : $attrs[
'ref'], $v, $use, $encodingStyle, $unqualified);
1524 $this->
debug(
"calling serialize_val() for $v, $eName, false, false, false, false, $use");
1525 $xml .= $this->
serialize_val($v, $eName,
false,
false,
false,
false, $use);
1529 if (isset($attrs[
'type']) || isset($attrs[
'ref'])) {
1531 $xml .= $this->
serializeType($eName, isset($attrs[
'type']) ? $attrs[
'type'] : $attrs[
'ref'], $v, $use, $encodingStyle, $unqualified);
1534 $this->
debug(
"calling serialize_val() for $v, $eName, false, false, false, false, $use");
1535 $xml .= $this->
serialize_val($v, $eName,
false,
false,
false,
false, $use);
1541 $this->
debug(
"no elements to serialize for XML Schema type $ns:$uqType");
1543 if (isset($typeDef[
'extensionBase'])) {
1544 $ns = $this->
getPrefix($typeDef[
'extensionBase']);
1545 $uqType = $this->
getLocalPart($typeDef[
'extensionBase']);
1549 if ($typeDef = $this->
getTypeDef($uqType, $ns)) {
1550 $this->
debug(
"serialize elements for extension base $ns:$uqType");
1553 $this->
debug(
"extension base $ns:$uqType is not a supported type");
1573 function addComplexType($name,$typeClass=
'complexType',$phpType=
'array',$compositor=
'',$restrictionBase=
'',$elements=array(),$attrs=array(),$arrayType=
'') {
1574 if (count($elements) > 0) {
1575 foreach($elements as
$n => $e){
1577 foreach ($e as $k => $v) {
1578 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
1579 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
1582 $eElements[
$n] = $ee;
1584 $elements = $eElements;
1587 if (count($attrs) > 0) {
1588 foreach($attrs as
$n => $a){
1590 foreach ($a as $k => $v) {
1591 $k = strpos($k,
':') ? $this->
expandQname($k) : $k;
1592 $v = strpos($v,
':') ? $this->
expandQname($v) : $v;
1600 $restrictionBase = strpos($restrictionBase,
':') ? $this->
expandQname($restrictionBase) : $restrictionBase;
1601 $arrayType = strpos($arrayType,
':') ? $this->
expandQname($arrayType) : $arrayType;
1603 $typens = isset($this->namespaces[
'types']) ? $this->namespaces[
'types'] : $this->namespaces[
'tns'];
1604 $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1618 function addSimpleType($name, $restrictionBase=
'', $typeClass=
'simpleType', $phpType=
'scalar', $enumeration=array()) {
1619 $restrictionBase = strpos($restrictionBase,
':') ? $this->
expandQname($restrictionBase) : $restrictionBase;
1621 $typens = isset($this->namespaces[
'types']) ? $this->namespaces[
'types'] : $this->namespaces[
'tns'];
1622 $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1633 $typens = isset($this->namespaces[
'types']) ? $this->namespaces[
'types'] : $this->namespaces[
'tns'];
1634 $this->schemas[$typens][0]->addElement($attrs);
1652 if ($use ==
'encoded' && $encodingStyle ==
'') {
1653 $encodingStyle =
'http://schemas.xmlsoap.org/soap/encoding/';
1656 if ($style ==
'document') {
1657 $elements = array();
1659 $elements[
$n] = array(
'name' =>
$n,
'type' =>
$t);
1661 $this->
addComplexType($name .
'RequestType',
'complexType',
'struct',
'all',
'', $elements);
1662 $this->
addElement(array(
'name' => $name,
'type' => $name .
'RequestType'));
1663 $in = array(
'parameters' =>
'tns:' . $name);
1665 $elements = array();
1667 $elements[
$n] = array(
'name' =>
$n,
'type' =>
$t);
1669 $this->
addComplexType($name .
'ResponseType',
'complexType',
'struct',
'all',
'', $elements);
1670 $this->
addElement(array(
'name' => $name .
'Response',
'type' => $name .
'ResponseType'));
1671 $out = array(
'parameters' =>
'tns:' . $name .
'Response');
1675 $this->bindings[ $this->serviceName .
'Binding' ][
'operations'][$name] =
1678 'binding' => $this->serviceName .
'Binding',
1679 'endpoint' => $this->endpoint,
1680 'soapAction' => $soapaction,
1685 'encodingStyle' => $encodingStyle,
1686 'message' => $name .
'Request',
1691 'encodingStyle' => $encodingStyle,
1692 'message' => $name .
'Response',
1695 'transport' =>
'http://schemas.xmlsoap.org/soap/http',
1701 foreach(
$in as $pName => $pType)
1703 if(strpos($pType,
':')) {
1706 $this->messages[$name.
'Request'][$pName] = $pType;
1709 $this->messages[$name.
'Request']=
'0';
1713 foreach(
$out as $pName => $pType)
1715 if(strpos($pType,
':')) {
1718 $this->messages[$name.
'Response'][$pName] = $pType;
1721 $this->messages[$name.
'Response']=
'0';