WSDL-SoapClient

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dheepu Kumar1
    New Member
    • Nov 2006
    • 3

    #1

    WSDL-SoapClient

    Hi All,

    I am i into php webservices development i have to
    access a WSDL file from client to a proxyservice(AL SB- AquaLogic)
    while generating request XML format type input is given to Soap.
    In that one namespace is being refered to another one namespace.
    dependency kinda thing, there a namespace is not being mapped to the
    referring namespace.
    Suggest me whether i am using corect way or thr is another work around.

    Pls do help me.

    TIA,
  • vssp
    Contributor
    • Jul 2006
    • 268

    #2
    Hai friend

    I am not clear Please can u expline breifly


    vssp

    Comment

    • Dheepu Kumar1
      New Member
      • Nov 2006
      • 3

      #3
      Originally posted by vssp
      Hai friend

      I am not clear Please can u expline breifly


      vssp

      Hai,

      First thanks for your humble reply.

      The problem which im facing is as follows:

      given below are complet set of code....

      hope ull hav a very good undetstanding by now.

      Issue #1 : namespaces are not being mapped properly.

      Issue #2 : If namespaces are mapped then the attribute "elementFormDefa ult" must be added.

      Needed Result : Without any change in WSDL by coding in PHP need to solve this problem.

      Anticipating ur fav reply.




      MyClient.php
      <?php
      include('myResp onse.php');
      include('MyRequ est.php');

      $myResponse = new myResponse();

      $MyRequest = new MyRequest();

      $MyRequest->CustomerNumb er = 123;
      $MyRequest->Unit = 'ABC';

      $myResponse ->MyRequest= $MyRequest;

      $client = new SoapClient('htt p://localhost/MyLocalProxy?WS DL',array('trac e'=>1));
      try{
      $response = $client->myResponse($my Response);
      $error = $response->MyResponse->error;
      echo "Error Code ".$error->ErrorCode."<br >";
      echo "Error Message ".$error->ErrorMessage." <br>";
      } catch (SoapFault $e) {
      echo $e;
      }

      echo "Last request Headers".$clien t->__getLastReque st()."<br>";
      echo "Last request ".$client->__getLastReque st()."<br>";
      echo "Last response <xmp>\n".
      $client->__getLastRespo nse()."</xmp><br><br>";

      ?>


      XML Request
      Required XML Request
      Following is the required XML request by the server before changing WSDL. Element MyRequest is mapped with ns1 namespace.

      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap .org/soap/envelope/" xmlns:ns1="http ://abc.com/GBTSTo/GBTSTReq/01" xmlns:ns2="http ://abc.com/GBTST">
      <SOAP-ENV:Body>
      <ns2:gBlTST>
      <ns1:GSTBTReq >
      <CustomerNumber >123</CustomerNumber>
      <Unit>ABC</Unit>
      </ns1:GSTBTReq>
      </ns2:gBlTST>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

      Generated XML Request before changing WSDL
      This is the XML request generated by the above PHP client code before changing the WSDL i.e. before adding elementFormDefa ult="qualified" in WSDL schema. Element GSTBTReq doesn’t contain namespace which causes ALSB[AquaLogicServic eBus] validation to fail.

      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap .org/soap/envelope/" xmlns:ns1="http ://abc.com/GBTST">
      <SOAP-ENV:Body>
      <ns1:gBTST>
      <GSTBTReq> <!— TODO : namespace not mapped here -- >
      <CustomerNumber >45</CustomerNumber>
      <Unit>DEF</Unit>
      </GSTBTReq>
      </ns1:gBTST>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>


      Generated XML Request after changing WSDL

      This is the XML request generated by the above PHP client code after changing the WSDL ie after adding elementFormDefa ult="qualified" in WSDL schema. Element GSTBTReq is now mapped with ns1 namespace. This input also gets the response from the server with no ALSB validation fail.


      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap .org/soap/envelope/" xmlns:ns1="http ://abc.com/GBTST/GBTSTReq/01" xmlns:ns2="http ://abc.com/GBTST">
      <SOAP-ENV:Body>
      <ns2:gBTST>
      <ns1:GSTBTReq >
      <ns1:CustomerNu mber>576</ns1:CustomerNum ber>
      <ns1:Unit>US</ns1:Unit>
      <ns1:GSTBTReq >
      </ns2:gBTST>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>



      Change in WSDL

      Following wsdl block is part of GBTST WSDL file. Attribute elementFormDefa ult="qualified" is added to the second schema which is required to generate required XML input.

      <s:schema elementFormDefa ult="qualified" targetNamespace ="http://abc.com/GBTST" xmlns:conv="htt p://www.openuri.org/2002/04/soap/conversation/" xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/" xmlns:http="htt p://schemas.xmlsoap .org/wsdl/http/"
      <s:import namespace="http ://abc.com/GBTST/GBTSTReq/01"/>
      <s:import namespace="http ://abc.com/GBTST/GBTSTResp/01"/>
      <s:element name="gBTST">
      <s:complexTyp e>
      <s:sequence>
      <s:element ref="ns:GSTBTRe q"/><!— TODO : element defined in other schema for which namespace is not mapped in the request -->
      </s:sequence>
      </s:complexType>
      </s:element>
      <s:element name= "gBTSTResp" >
      <s:complexTyp e>
      <s:sequence>
      <s:element ref="ns1:GSTBTR esp"/>
      </s:sequence>
      </s:complexType>
      </s:element>
      </s:schema>

      <!— TODO : Added attribute elementFormDefa ult="qualified" to solve the problem -- >

      <s:schema elementFormDefa ult="qualified" targetNamespace ="http://abc.com/GBTST/GBTSTReq/01" xmlns:common="h ttp://abc.com/Common/01" xmlns:conv="htt p://www.openuri.org/2002/04/soap/conversation/" xmlns:cw="http://www.openuri.org/2002/04/wsdl/conversation/" xmlns:http="htt p://schemas.xmlsoap .org/wsdl/http/"
      xmlns:req="http ://abc.com/GBTST/GBTSTReq/01" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap="htt p://schemas.xmlsoap .org/wsdl/soap/" xmlns:soapenc=" http://schemas.xmlsoap .org/soap/encoding/" xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
      <s:import namespace="http ://abc.com/Common/01"/>
      <s:simpleType name="CustomerN umber">
      <s:restrictio n base="xsd:integ er"/>
      </s:simpleType>
      <s:simpleType name="Unit">
      <s:restrictio n base="xsd:strin g">
      <s:enumeratio n value="ABC"/>
      </s:restriction>
      </s:simpleType>
      <s:element name="GSTBTReq" >
      <s:complexTyp e>
      <s:sequence>
      <s:element name="CustomerN umber" nillable="false " type="req:Custo merNumber"/>
      <s:element name="Unit" nillable="false " type="req:Opera tingUnit"/>
      </s:sequence>
      </s:complexType>
      </s:element>
      </s:schema>





      Thanks in Advance ...

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        This the second notice:

        Read the Posting Guidelines before you put anything in here. Take special notice of the part saying that you must enclose you code within code, php or html tags.!!


        Ronald :cool:

        Comment

        Working...