Archive

Archive for the ‘SOAP’ Category

Undefined offset: 0 in ..\SOAP\Transport\HTTP.php on line 341

December 13, 2010 admin No comments
'HTTP/1.1 200 OK
Date: Mon, 13 Dec 2010 19:42:59 GMT
Server: Apache/2.2.16 (Win32) PHP/5.3.3
X-Powered-By: PHP/5.3.3
Set-Cookie: symfony=c7negjfjla0njaej17lo89hjl2; path=/
Content-Length: 2701
Connection: close
Content-Type: text/xml; charset=UTF-8
X-Pad: avoid browser bug'

 

SOAP\Transport\HTTP.php

    /**
     * Parses the headers.
     *
     * @param array $headers  The headers.
     */
    function _parseHeaders($headers)
    {
        /* Largely borrowed from HTTP_Request. */
        $this->result_headers = array();
        $headers = explode("\r?\n", $headers);
        foreach ($headers as $value) {
            if (strpos($value,':') === false) {
                $this->result_headers[0] = $value;
                continue;
            }
            list($name, $value) = explode(':', $value);
            $headername = strtolower($name);
            $headervalue = trim($value);
            $this->result_headers[$headername] = $headervalue;

 

    /**
     * Parses the headers.
     *
     * @param array $headers  The headers.
     */
    function _parseHeaders($headers)
    {
        /* Largely borrowed from HTTP_Request. */
        $this->result_headers = array();
        $headers = str_replace("\r","",$headers);
        $headers = explode("\n",$headers);
        foreach ($headers as $value) {
            if (strpos($value,':') === false) {
                $this->result_headers[0] = $value;
                continue;
            }
            list($name, $value) = explode(':', $value);
            $headername = strtolower($name);
            $headervalue = trim($value);
            $this->result_headers[$headername] = $headervalue;

 

Categories: SOAP, Troubleshooting Tags:

PHP & PEAR SAOP

February 17, 2010 admin No comments
# pear install -f --alldeps SOAP

soapservice.php

<?php
require_once 'PEAR.php';
require_once 'SOAP/Server.php';
require_once 'SOAP/Disco.php';
require_once 'SOAP/Value.php';
require_once 'SOAP/Fault.php'; 

$skiptrace =& PEAR::getStaticProperty('PEAR_Error', 'skiptrace');
$skiptrace = true; 

class Service {
	var $__dispatch_map = array(); 

	function Service()
	{
		$this->__dispatch_map['now'] = array(
			'in' => array('format' => 'string'),
			'out' => array('time' => 'dateTime'));
	}
	function now($format)
	{
		if($format == '')
		{
			return new SOAP_Fault("Falscher Paramerter!","0815","Client");
		}

		return new SOAP_Value('time','dateTime',date($format));
	}
} 

$server = new SOAP_Server();
$service = new Service();
$server->addObjectMap($service, 'urn:soapservice'); 

if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD']=='POST')
{
	$server->service($HTTP_RAW_POST_DATA);
}
else
{
	// Create the DISCO server
	$disco = new SOAP_DISCO_Server($server,'soapservice');
	header('Content-type: text/xml');
	if (isset($_SERVER['QUERY_STRING']) && strcasecmp($_SERVER['QUERY_STRING'],'wsdl') == 0)
	{
		echo $disco->getWSDL();
	}
	else
	{
		echo $disco->getDISCO();
	}
}
?>

http://localhost/soapservice.php?wsdl

<?xml version="1.0" ?>
<definitions name="soapservice"
	targetNamespace="urn:soapservice"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:tns="urn:soapservice"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
	xmlns="http://schemas.xmlsoap.org/wsdl/">

	<types xmlns="http://schemas.xmlsoap.org/wsdl/" />
	<message name="nowRequest">
<part name="format" type="xsd:string" />
	</message>
	<message name="nowResponse">
<part name="time" type="xsd:dateTime" />
	</message>
<portType name="soapservicePort">
		<operation name="now">
			<input message="tns:nowRequest" />
			<output message="tns:nowResponse" />
		</operation>
	</portType>
	<binding name="soapserviceBinding" type="tns:soapservicePort">
		<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
		<operation name="now">
			<soap:operation soapAction="urn:soapservice#Service#now" />
			<input>
				<soap:body use="encoded" namespace="urn:soapservice" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
			</input>
			<output>
				<soap:body use="encoded" namespace="urn:soapservice" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
			</output>
		</operation>
	</binding>
	<service name="soapserviceService">
		<documentation />
<port name="soapservicePort" binding="tns:soapserviceBinding">
			<soap:address location="http://localhost:8182/soapservice.php" />
		</port>
	</service>
</definitions>

VB SOAP Samples
Download VB Source

Option Explicit

Private Sub cmdGo_Click()
        Dim SOAPSerializer As MSSOAPLib30.SoapSerializer30
        Dim SOAPConnector As MSSOAPLib30.SoapConnector30
        Dim SOAPReader As MSSOAPLib30.SoapReader30

        Set SOAPConnector = New MSSOAPLib30.HttpConnector30

        On Error Resume Next
        Err.Clear

        SOAPConnector.Property("EndPointURL") = txtUrl.Text '"http://localhost/soapservice.php"
        SOAPConnector.Connect

        ' Set Method Call
        SOAPConnector.Property("SoapAction") = "urn:soapservice"
        SOAPConnector.BeginMessage

        Set SOAPSerializer = New MSSOAPLib30.SoapSerializer30
        SOAPSerializer.Init SOAPConnector.InputStream

        SOAPSerializer.StartEnvelope
        SOAPSerializer.StartBody

        SOAPSerializer.StartElement "now", "urn:soapservice"
        SOAPSerializer.StartElement "Format"
        SOAPSerializer.WriteString txtFormat.Text ' "Y-m-d"
        SOAPSerializer.EndElement
        SOAPSerializer.EndElement

        SOAPSerializer.EndBody
        SOAPSerializer.EndEnvelope

        ' Tell the serializer that we are finished providing all message
        SOAPSerializer.Finished
        SOAPConnector.EndMessage

        If Err.Number = 0 Then
                Set SOAPReader = New MSSOAPLib30.SoapReader30
                SOAPReader.Load SOAPConnector.OutputStream
                If Not SOAPReader.Fault Is Nothing Then
                        txtResult.Text = SOAPReader.FaultString.Text
                        txtResult.BackColor = &HC0C0FF
                Else
                        txtResult.Text = SOAPReader.RpcResult.Text
                        txtResult.BackColor = &HC0FFC0
                End If
        Else
                txtResult.Text = Err.Number
                txtResult.BackColor = &HFF&
        End If
End Sub

MS Download Page SOAP Toolkit 3.0
VB SOAP Samples

Categories: PHP, SOAP Tags:

ModSecurity AuditLog: HTTP/1.1 500 SOAP Fault (PEAR::SOAP & Mod_Security 2.5.11)

February 4, 2010 admin No comments
...
$server = new SOAP_Server();
$service = new Service();
$server->_options['http_status_fault'] = '200 SOAP Fault'; // old status '500 SOAP Fault';
...

Links:

Categories: PHP, SOAP, Troubleshooting Tags: