www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help with SOAP messaging (schema and wsdl)

  1. #1
    Join Date
    Aug 2006
    Posts
    170

    Question Help with SOAP messaging (schema and wsdl)

    Hello all.

    I'm attempting to get some web services up and running using PHP, and I'm having a hell of a time getting things to work properly. Before I eliminate PHP from the equation, I need to be absolutely sure that my schema and wsdl documents are correct. The problem that I'm having is that PHP is complaining that my types are unknown, and PHP SOAP support/documentation sucks at best.

    This is my first attempt at creating/consuming web services, so it's a little difficult to know if I have all the syntax correct. From everything that I've read over the past week, it would appear that I'm following the standards and doing things the correct way. I'm a bit confused with the whole namespace thing, however, as I don't know if I'm supposed to prepend certain elements or where exactly I should be defining my namespaces. Following examples and reading through the specs, again, it appears that I have things in order.

    If possible, I'd like some feedback on the following documents. Essentially, UserDefinedDataTypes.xsd defines some custom types. Agent.xsd/Result.xsd includes UserDefinedDataTypes.xsd, then both of those schemas are included in AccountManagement.wsdl. I'm leaving Result.xsd out because it's pretty much the same as Agent.xsd, with exception to the elements returned.

    UserDefinedDataTypes.xsd
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema id                  ="UserDefinedDataTypes"
                elementFormDefault  ="qualified"
                targetNamespace     ="http://www.company.com/AccountManagement"
                xmlns:tns           ="http://www.company.com/AccountManagement"
                xmlns:xsd           ="http://www.w3.org/1999/XMLSchema"
                xmlns               ="http://schemas.xmlsoap.org/wsdl/">
    			
        <xsd:simpleType name="t_id">
            <xsd:restriction base="xsd:string">
                <xsd:pattern value="[0-9]{10}" />
            </xsd:restriction>
        </xsd:simpleType>
    	
        <xsd:simpleType name="t_guid">
            <xsd:restriction base="xsd:string">
                <xsd:pattern value="\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}" />
                <xsd:pattern value="" />
            </xsd:restriction>
        </xsd:simpleType>
    	
        <xsd:simpleType name="t_description">
            <xsd:restriction base="xsd:string">
                <xsd:minLength value="0" />
                <xsd:maxLength value="256" />
            </xsd:restriction>
        </xsd:simpleType>
    </xsd:schema>

    Agent.xsd:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsd:schema id                  ="Agent"
                elementFormDefault  ="qualified"
                targetNamespace     ="http://www.company.com/AccountManagement"
                xmlns:tns           ="http://www.company.com/AccountManagement"
                xmlns:xsd           ="http://www.w3.org/1999/XMLSchema"
                xmlns               ="http://schemas.xmlsoap.org/wsdl/">
    			
        <xsd:include schemaLocation="UserDefinedDataType.xsd" />
    	
        <xsd:complexType name="Agent">
            <xsd:sequence>
                <xsd:element name="PartnerId"       type="t_id" />
                <xsd:element name="PartnerAgentId"  type="t_guid" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:schema>

    AccountManagement.wsdl:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <definitions name            ="AccountManagement"
                 targetNamespace ="http://www.company.com/AccountManagement"
                 xmlns:tns       ="http://www.company.com/AccountManagement"
                 xmlns:xsd       ="http://www.w3.org/1999/XMLSchema"
                 xmlns:soap      ="http://schemas.xmlsoap.org/wsdl/soap/"	 			
                 xmlns           ="http://schemas.xmlsoap.org/wsdl/">
    			 
        <types>
            <xsd:schema targetNamespace="http://www.company.com/AccountManagement" xmlns="http://www.w3.org/1999/XMLSchema/">
                <xsd:include schemaLocation="Agent.xsd" />
                <xsd:include schemaLocation="Result.xsd" />
            </xsd:schema>
        </types>
    			 
        <message name="createRequest">
            <part name="Agent" type="tns:Agent" />
        </message>
        <message name="createResponse">
            <part name="Result" type="tns:Return" />
        </message>
    
        <portType name="AccountManagement_portType">
            <operation name="create">
                <input message="tns:createRequest" />
                <output message="tns:createResponse" />
            </operation>
        </portType>
    	
        <binding name="AccountManagement_binding" type="tns:AccountManagement_portType">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
            <operation name="create">
                <soap:operation soapAction="" />
                <input><soap:body use="encoded" namespace="urn:AccountManagement" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /></input>
                <output><soap:body use="encoded" namespace="urn:AccountManagement" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /></output>
            </operation>
        </binding>
    	
        <service name="AccountManagement">
            <port name="AccountManagement_port" binding="tns:AccountManagement_binding">
                <soap:address location="http://www.company.com/AccountManagement.php"/>
            </port>
        </service>
    </definitions>

    Any feedback is greatly appreciated, and thanks in advance.

  2. #2
    Join Date
    Aug 2006
    Posts
    170
    BTW, I should mention that when I use the standard types (xsd:string, xsd:integer, etc.) directly in my WSDL to define the elements, everything works properly. It's only when I take those out and put them in separate schema files that I'm having a problem.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles