无法使用BeSimpleSOAP客户端连接到主机

时间:2013-12-19 13:22:40

标签: php xml soap xsd wsdl

我正在尝试使用PHP SOAP客户端发送测试消息。我正在使用BeSimpleSoap库,因为我遇到了标准PHP SOAP calss和NuSOAP类的问题。 这是我的剧本:

<?php

function __autoload($class_name) {
    include "C:\\xampp\\htdocs\\NIAS\\BeSimpleSoap-master\\src\\" .$class_name . '.php';
}


$date_time = date("Y-m-d") . "T" . date("G") . ":" . date("i") . ":" . date("s");

$par_data = new StdClass(); 
$par_data->encoding = "EMBEDDED"; 
$par_data->any = "U2FkcsW+YWogbmVrZSB0ZXN0bmUgcG9ydWtl";


        $par_envelope=array( "GsbEnvelope" =>  
        array( "MessageHeader" => 
            array("SenderId" => "000000001",
                "ServiceId" => "000000002",
                "MessageId" => "833362f-063f-11e2-892e-0802200c9a62",
                "SenderTimeStamp" => $date_time),
                "Content" => array("MimeType" =>"application/xml","Data" =>$par_data)));

$client = new BeSimple\SoapClient\SoapClient("GSBService.wsdl", array( 
                            "trace"=>1,
                            "exceptions"=>1,
                            "connection_timeout" => 120));


print_r( $client->sendMessage($par_envelope));



echo "<p>Request :".htmlspecialchars($client->__getLastRequest()) ."</p>";
echo "<p>Response:".htmlspecialchars($client->__getLastResponse())."</p>";
echo "<p>Debug:".soapDebug($client)."</p>";

  ?>

这是WSDL文件:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="GSBService"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.apis-it.hr/umu/2013/services/GSBService"
    xmlns:umu="http://www.apis-it.hr/umu/2013/services/GSBService"
    xmlns:gsb="http://apis-it.hr/umu/2013/types/gsb">

  <wsdl:types>
    <xsd:schema targetNamespace="http://www.apis-it.hr/umu/2013/services/GSBService">
        <xsd:import namespace="http://apis-it.hr/umu/2013/types/gsb" schemaLocation="../schema/GSBSchema.xsd"/>
    </xsd:schema>
  </wsdl:types>

  <wsdl:message name="SendMessageRequest">
    <wsdl:part element="gsb:SendMessageRequest" name="request"/>
  </wsdl:message>
  <wsdl:message name="SendMessageResponse">
    <wsdl:part element="gsb:SendMessageResponse" name="response"/>
  </wsdl:message>

  <wsdl:message name="EchoRequest">
    <wsdl:part element="gsb:EchoRequest" name="request" />
  </wsdl:message>
  <wsdl:message name="EchoResponse">
    <wsdl:part element="gsb:EchoResponse" name="response" />
  </wsdl:message>

  <wsdl:portType name="GSBServicePortType">
    <wsdl:operation name="sendMessage">
      <wsdl:input message="umu:SendMessageRequest"/>
      <wsdl:output message="umu:SendMessageResponse"/>
    </wsdl:operation>
    <wsdl:operation name="echo">
        <wsdl:input message="umu:EchoRequest"/>
        <wsdl:output message="umu:EchoResponse"/>
    </wsdl:operation>
  </wsdl:portType>

  <wsdl:binding name="GSBService" type="umu:GSBServicePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sendMessage">
      <soap:operation soapAction="http://www.apis-it.hr/umu/2013/services/GSBService/sendMessage"/>
      <wsdl:input>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="echo">
        <soap:operation soapAction="http://www.apis-it.hr/umu/2013/services/GSBService/echo"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="GSBService">
    <wsdl:port binding="umu:GSBService" name="GSBServicePortType">
      <soap:address location="http://www.apis-it.hr:8849/GsbService"/>
    </wsdl:port>
  </wsdl:service>

</wsdl:definitions>

这是xsd架构文件:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://apis-it.hr/umu/2013/types/gsb"
    xmlns:tns="http://apis-it.hr/umu/2013/types/gsb" xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
    elementFormDefault="qualified">

    <import namespace="http://www.w3.org/2000/09/xmldsig#"
        schemaLocation="../schema/xmldsig-core-schema.xsd" />

    <element name="SendMessageRequest">
        <annotation>
            <documentation>
                Send message service request
            </documentation>
        </annotation>
        <complexType>
            <sequence>
                <element name="GsbEnvelope" type="tns:GsbEnvelopeType" minOccurs="1" maxOccurs="1"/>
            </sequence>
        </complexType>
    </element>

    <element name="SendMessageResponse">
        <annotation>
            <documentation>
                Send message service response
            </documentation>
        </annotation>
        <complexType>
            <sequence>
                <element name="MessageHeader" type="tns:MessageHeaderType" minOccurs="0" maxOccurs="1" />
                <element name="Content" type="tns:ContentType" minOccurs="0" maxOccurs="1" />
                <element name="Errors" type="tns:ErrorsType" minOccurs="0" maxOccurs="1" />
                <element ref="ds:Signature" minOccurs="0" maxOccurs="1" />
            </sequence>
        </complexType>
    </element>

    <element name="EchoRequest" type="string" nillable="false">
        <annotation>
            <documentation>Poruka echo metodi.</documentation>
        </annotation>
    </element>

    <element name="EchoResponse" type="string" nillable="false">
        <annotation>
            <documentation>Odgovor echo metode u obliku: "Request:
                'echoRequest'. Response: 'yyyy-MM-dd'T'HH:mm:ss.SSSZ'.
            </documentation>
        </annotation>
    </element>


    <complexType name="GsbEnvelopeType">
        <annotation>
            <documentation>
                Envelope used in gsb communication
        </documentation>
        </annotation>
        <sequence>
            <element name="MessageHeader" type="tns:MessageHeaderType"
                minOccurs="1" maxOccurs="1" />
            <element ref="ds:Signature" minOccurs="0" maxOccurs="1" />
            <element name="Content" type="tns:ContentType" minOccurs="1"
                maxOccurs="1" />
        </sequence>
    </complexType>

    <complexType name="MessageHeaderType">
        <sequence>
            <element name="SenderId" type="tns:SenderIdType" minOccurs="1" maxOccurs="1" />
            <element name="ServiceId" type="tns:ServiceIdType" minOccurs="1" maxOccurs="1" />
            <element name="AditionalServiceId" type="tns:ServiceIdType" minOccurs="0" maxOccurs="1" />
            <element name="MessageId" type="tns:UUIDType" minOccurs="1" maxOccurs="1" />
            <element name="GsbId" type="tns:UUIDType" minOccurs="0" maxOccurs="1" />
            <element name="SenderTimeStamp" type="dateTime" minOccurs="1" maxOccurs="1" />
            <element name="ReceivingTimeStamp" type="dateTime" minOccurs="0" maxOccurs="1" />
            <element name="ForwardingTimeStamp" type="dateTime" minOccurs="0" maxOccurs="1" />
            <element name="ReceiverTimeStamp" type="dateTime" minOccurs="0" maxOccurs="1" />
            <element name="ReplyReceivingTimeStamp" type="dateTime" minOccurs="0" maxOccurs="1" />
            <element name="ReplyForwardingTimeStamp" type="dateTime" minOccurs="0" maxOccurs="1" />
            <element name="ExchangeStatus" type="tns:StatusType" minOccurs="0" maxOccurs="1" />
        </sequence>
    </complexType>

    <complexType name="ContentType">
        <sequence>
            <element name="MimeType" type="string" minOccurs="1"
                maxOccurs="1" />
            <element name="Description" type="string" minOccurs="0"
                maxOccurs="1">
                <annotation>
                    <documentation>
                        Optional document description. Max lenght 255
                        characters.
            </documentation>
                </annotation>
            </element>
            <element name="Data" minOccurs="1" maxOccurs="1">
                <complexType mixed="true">
                    <sequence minOccurs="0" maxOccurs="unbounded">
                        <any namespace="##any" processContents="lax" />
                    </sequence>
                    <attribute name="encoding" use="required">
                        <simpleType>
                            <restriction base="string">
                                <enumeration value="EMBEDDED" />
                                <enumeration value="BASE64" />
                            </restriction>
                        </simpleType>
                    </attribute>
                    <anyAttribute namespace="##any" />
                </complexType>
            </element>
        </sequence>
    </complexType>

    <complexType name="ErrorsType">
        <sequence>
            <element name="Error" type="tns:ErrorType" minOccurs="1"
                maxOccurs="unbounded" />
        </sequence>
    </complexType>

    <complexType name="ErrorType">
        <sequence>
            <element name="ErrorCode" type="tns:ErrorCodeType" minOccurs="1"
                maxOccurs="1" />
            <element name="ErrorMessage" type="tns:ErrorMessageType"
                minOccurs="1" maxOccurs="1" />
        </sequence>
    </complexType>

    <simpleType name="ErrorCodeType">
        <restriction base="string">
            <pattern value="s[0-9]{3}" />
        </restriction>
    </simpleType>

    <simpleType name="ErrorMessageType">
        <restriction base="string">
            <maxLength value="500" />
        </restriction>
    </simpleType>


    <simpleType name="SenderIdType">
        <restriction base="string">
            <minLength value="1" />
            <maxLength value="9" />
            <pattern value="[0-9]+" />
        </restriction>
    </simpleType>

    <simpleType name="StatusType">
        <restriction base="string">
            <minLength value="1" />
            <maxLength value="1" />
        </restriction>
    </simpleType>

    <simpleType name="ServiceIdType">
        <restriction base="string">
            <minLength value="1" />
            <maxLength value="9" />
            <pattern value="[0-9]+" />
        </restriction>
    </simpleType>

    <simpleType name="UUIDType">
        <restriction base="string">
            <pattern
                value="[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}" />
        </restriction>
    </simpleType>

</schema>

我收到了这个错误:

Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in C:\xampp\htdocs\NIAS\BeSimpleSoap-master\src\BeSimple\SoapClient\SoapClient.php:146 Stack trace: #0 C:\xampp\htdocs\NIAS\BeSimpleSoap-master\src\BeSimple\SoapClient\SoapClient.php(203): BeSimple\SoapClient\SoapClient->__doHttpRequest(Object(BeSimple\SoapClient\SoapRequest)) #1 C:\xampp\htdocs\NIAS\BeSimpleSoap-master\src\BeSimple\SoapClient\SoapClient.php(183): BeSimple\SoapClient\SoapClient->__doRequest2(Object(BeSimple\SoapClient\SoapRequest)) #2 [internal function]: BeSimple\SoapClient\SoapClient->__doRequest('<?xml version="...', 'http://www.apis...', 'http://www.apis...', 1, 0) #3 C:\xampp\htdocs\NIAS\HZZO-OKP-SOAP.php(53): SoapClient->__call('sendMessage', Array) #4 C:\xampp\htdocs\NIAS\HZZO-OKP-SOAP.php(53): BeSimple\SoapClient\SoapClient->sendMessage(Array) #5 {main} thrown in C:\xampp\htdocs\NIAS\BeSimpleSoap-master\src\BeSimple\SoapClient\SoapClient.php on line 146

0 个答案:

没有答案