XML to webservice

JDS

Active Member
Licensed User
Longtime User
I have an file with an signature which needs to be send to a webservice.
This service expects the following:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <PutStatusXML7 xmlns="http://tempuri.org/">
      <iUser>int</iUser> 'int should be replaced with an integer
      <sPass>string</sPass> 'string should be replaced
      <XMLFile>anyType</XMLFile> 'anytype is an xmlfile with tags
    </PutStatusXML7>
  </soap:Body>
</soap:Envelope>

The Xml I've build is exactly the same:
B4X:
<?XML version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<PutStatus xmlns="http://tempuri.org/">
<iUser>1201</iUser>
<sPass>jds</sPass>
<XMLFile><zendingen><status><s01>1201</s01><s02>13-09-2012</s02><s03>0</s03><s04>14:52:52</s04><s05>13-09-2012</s05><s06>300406</s06><s07>2507</s07><s08>1201-300406-09132012.bmp</s08><s09>Op bestellijst</s09><s10>9448</s10><s11></s11><s12></s12><s13></s13><s14>1</s14><s15>0</s15>
</status></zendingen></XMLFile>
</PutStatus></soap:Body></soap:Envelope>

I'm calling the service with:
B4X:
Sub PutStatus
   Dim I, iTotal, J As Int
   Dim lFiles As List
   Dim sParameter, sNewFile, sChar, sSoap, requestSoapXML As String
   Dim Soap As HttpJob
   I = 1
   lFiles.Initialize
   lFiles = File.ListFiles(Map_Wachtrij)
   If (lFiles.Size>0) Then
      sNewFile =  lFiles.Get(0)
      sParameter = "<?XML version="& QUOTE & "1.0" &QUOTE &" encoding="&QUOTE& "utf-8"  & QUOTE&"?><soap:Envelope xmlns:soap="&QUOTE& "http://schemas.xmlsoap.org/soap/envelope/"&QUOTE&"><soap:Body><PutStatus xmlns="& QUOTE& "http://tempuri.org/"&QUOTE&">"
      sParameter = sParameter & "<iUser>" & Main.uniqueID & "</iUser><sPass>" & Main.Pass& "</sPass><XMLFile>"
         sParameter = sParameter & File.ReadString(Map_Wachtrij,sNewFile)
      sParameter = sParameter & "</XMLFile></PutStatus></soap:Body></soap:Envelope>"
      
      ProgressDialogShow(lFiles.size & " status(sen) te versturen...")
      
      Soap.Initialize("PutStatus","GlobalService")
      HttpUtils.CallbackUrlDoneSub = "" 'don't want to handle this event
       Log(sParameter)
      Soap.PostString(Main.MainUrl, sParameter.Trim)
   End If
End Sub

The log says:
The server cannot service the request because the media type is unsupported.
JobName = PutStatus, Success = false
Error: Unsupported Media Type

sParameter is the xml-code. Should I use an other call? What does the log "Error: Unsupported Media Type" mean?
 

JDS

Active Member
Licensed User
Longtime User
Use:
...
...
Soap.Initialize("PutStatus","GlobalService")
Soap.SetContentType("text/xml")
...
...



Hi Edgar,

I'm using HttpJob, therefor "Soap.SetContentType" isn't know.
Still trying to get the XMLRPC1 to work.
 
Last edited:
Upvote 0

JDS

Active Member
Licensed User
Longtime User
I've tried the following

B4X:
Sub PutStatus
   Dim I, iTotal, J As Int
   Dim lFiles As List
   Dim sParameter, sNewFile, requestSoapXML As String
   Dim Soap As HttpJob
   I = 1
   lFiles.Initialize
   lFiles = File.ListFiles(Map_Wachtrij)
   If (lFiles.Size>0) Then
      sNewFile =  lFiles.Get(0)
      sParameter = "<?XML version="& QUOTE & "1.0" &QUOTE &" encoding="&QUOTE& "utf-8"  & QUOTE&"?><soap:Envelope xmlns:soap="&QUOTE& "http://schemas.xmlsoap.org/soap/envelope/"&QUOTE&"><soap:Body><PutStatusXML7 xmlns="& QUOTE& "http://tempuri.org/"&QUOTE&">"
      sParameter = sParameter & "<iPda>" &QUOTE & Main.uniqueID &QUOTE& "</iPda><sWachtwoord>" & Main.wachtwoord & "</sWachtwoord><XMLFile>"&QUOTE
         sParameter = sParameter & File.ReadString(Map_Wachtrij,sNewFile)
      sParameter = sParameter & QUOTE & "</XMLFile></PutStatusXML7></soap:Body></soap:Envelope>"
      
      Dim XMLRPC1 As XMLRPC : XMLRPC1.initialize("PutStatus")
      XMLRPC1.initXMLRPCClient(Main.MainUrl)'("your website")
      XMLRPC1.stringCall("PutStatusXML7",sParameter.Trim)
   End If
End Sub

Without any result. Errorlog says:
"org.xmlrpc.android.XMLRPCException: HTTP status code: 500 != 200"`

Any ideas? I've got a lot more of this kind a calls. If I've got one working the rest will follow... :BangHead:
 
Upvote 0
Top