Android Question Access Data from PHP WSDL using HttpJob

Discussion in 'Android Questions' started by phukol, Jun 7, 2015.

  1. phukol

    phukol Active Member Licensed User

    Good day Guys!

    Just want to ask. Im using a wsdl generated from php. Using httpjob, i am trying to post a request to the file and receive an xml response. The problem is, the response is the xml code of the wsdl file. Can someone direct me to the right path? I am trying to call the login function

    wsdl file: (sample)
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <definitions xmlns:SOAP-ENV=
    "http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:coreon.gcash" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:coreon.gcash">
    <types>
    <xsd:schema targetNamespace=
    "urn:coreon.gcash">
    <xsd:import namespace=
    "http://schemas.xmlsoap.org/soap/encoding/" />
    <xsd:import namespace=
    "http://schemas.xmlsoap.org/wsdl/" />
        <xsd:complexType name=
    "resultInfo">
            <xsd:all>
                <xsd:element name=
    "result" type="xsd:string"/>
                <xsd:element name=
    "transid" type="xsd:string"/>
                <xsd:element name=
    "msg" type="xsd:string"/>
                <xsd:element name=
    "session" type="xsd:string"/>
            </xsd:all>
        </xsd:complexType>
    </xsd:schema>
    </types>
    <message name=
    "loginRequest">
      <
    part name="id" type="xsd:string" />
      <
    part name="password" type="xsd:string" /></message>
    <message name=
    "loginResponse">
      <
    part name="return" type="xsd:resultInfo" /></message>
    <portType name=
    "coreon.gcashPortType">
      <operation name=
    "login">
        <documentation>User Login</documentation>
        <input message=
    "tns:loginRequest"/>
        <output message=
    "tns:loginResponse"/>
      </operation>
    </portType>
    <binding name=
    "coreon.gcashBinding" type="tns:coreon.gcashPortType">
      <soap:binding style=
    "rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name=
    "login">
        <soap:operation soapAction=
    "uri:coreon.gcash#login" style="rpc"/>
        <input><soap:body use=
    "encoded" namespace="uri:coreon.gcash" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input>
        <output><soap:body use=
    "encoded" namespace="uri:coreon.gcash" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output>
      </operation>
    </binding>

    code:
    Code:
    Sub consumeService(strOpt As  String,data1 As String,data2 As String,data3 As String,data4 As String,data5 As String,data6 As String,data7 As String,data8 As String)
        
    Dim PostUrl As String = ""
        
    Dim strXML As String=""
        
    Dim job1 As HttpJob
        
        
    Select Case strOpt
      
            
    Case "1" 'Login
                PostUrl = "http://xxxx.5.xxx.xxx/coreonCash_dev4/pages/Coreon_GCash.wsdl"
                strXML = 
    "<?xml version='1.0' encoding='UTF-8'?>"
               strXML = strXML & 
    "<SOAP-ENV:Envelope xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' "
                strXML = strXML & 
    "xmlns:ns1='uri:coreon.gcash' xmlns:xsd='http://www.w3.org/2001/XMLSchema' "
               strXML = strXML & 
    "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' "
                strXML = strXML & 
    "SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>"
                strXML = strXML & 
    "<SOAP-ENV:Body>"
                strXML = strXML & 
    "<ns1:loginRequest>"
                strXML = strXML & 
    "<id xsi:type='xsd:String'>" & data1 & "</id>"
                strXML = strXML & 
    "<password xsi:type='xsd:String'>" & data2 & "</password>"
                strXML = strXML & 
    "</ns1:login>"
                strXML = strXML & 
    "</SOAP-ENV:Body>"
               strXML = strXML & 
    "</SOAP-ENV:Envelope>"
               strXML = strXML.Replace(
    "'"Chr(34))
            
                job1.Initialize(
    "login", Me)
            
            job1.PostString(PostUrl, strXML)
            job1.GetRequest.SetContentType(
    "text/xml; charset=utf-8")
        
        
    End Select
    End Sub

    Sub JobDone (Job As HttpJob)

        
    If Job.Success Then
               
    Select Job.JobName
                   
    Case "login"
                        
    Log(Job.GetString)
                        parser.Initialize()
                        parser.Parse(Job.GetInputStream , 
    "Parser")
               
    End Select
        
    Else
         
            
    Msgbox"Error in Accessing Web Portal," & CRLF & "Make sure you are connected to the Internet!""Error")
            
    'Msgbox( Job.errormessage , "Error")
        End If
        Job.Release
    End Sub

    Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
      
        
    If parser.Parents.IndexOf("login") > -1 Then 'login
            If Name = "session" Then
                strSession = Text.ToString
            
    Else If Name = "result" Then
                strResult = Text.ToString
            
    End If
        
    End If
        
    End Sub
    i have already done this using actual php code and .net asmx, i was able to get the result but im kind of confuse how i can execute it using wsdl
     
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. phukol

    phukol Active Member Licensed User

    Thanks Erel I changed this code:
    Code:
    job1.PostString(PostUrl, strXML)
            job1.GetRequest.SetHeader(
    "login""http://xxxxxxx/coreonCash_dev4/pages/Coreon_GCash.wsdl")
            job1.GetRequest.SetContentType(
    "text/xml; charset=utf-8")
    but its still outputting the code of my wsdl and not the output i need.

    How can i make use of smart string literal in this scenario.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You are probably not calling the correct link. You can use a tool such as WireShark or Fiddler to see the network requests sent from the PC.

    About the string literal:
    Code:
    strXML = $"here
    you can just put all the xml content. No need to 
    escape anything
     and you can fill the fields with $xml{
    data1} and $xml{data2}"$
     
  5. phukol

    phukol Active Member Licensed User

    thank you Erel, but i was able to use the wsdl using actual php code and it'w working fine for asp.net and php, i am quite confused because im sending the actual XML request already but the output is always the xml code of the wsdl web service.

    I also tried Fiddler but its also outputting my wsdl code
     
    Last edited: Jun 9, 2015
  6. phukol

    phukol Active Member Licensed User

    Hello everyone.
    I figured it out. I dont know what seems to be the problem but Fiddler is also outputting the XML of my wsdl.
    what i did was to use the actual php page that my wsdl uses for its function.
    so instead of using
    PostUrl = "http://xxxx.5.xxx.xxx/coreonCash_dev4/pages/Coreon_GCash.wsdl"

    i used
    PostUrl = "http://xxxx.5.xxx.xxx/coreonCash_dev4/pages/CoreonService.php"

    which is used for the wsdl file. I also changed the SetHeader to the url of the code

    job1.GetRequest.SetHeader("login", "http://xxxxx/rommel/coreonCash_dev4/pages/CoreonService.php")
     
Loading...