1
votes

I'm in trouble now.

I tried to use R for SOAP data exchange, but always get the server to respond as follows:

Trying 210.242.163.56...

Connected to 210.242.163.56 (210.242.163.56) port 80 (#0)

POST /SendDigXml/ HTTP/1.1

Host: 210.242.163.56

Accept: text/xml

Accept: multipart/*

Content-Type: text/xml; charset=utf-8

SOAPAction: http://210.242.163.56/SendDigXml/GetLastMod

Content-Length: 397

upload completely sent off: 397 out of 397 bytes

< HTTP/1.1 500 Internal Server Error

< Cache-Control: private

< Content-Type: text/xml; charset=utf-8

< Server: Microsoft-IIS/7.5

< X-AspNet-Version: 4.0.30319

< X-Powered-By: ASP.NET

< Date: Tue, 01 Nov 2016 06:32:54 GMT

< Content-Length: 441

< Connection: Keep-Alive

< Age: 0

< Connection #0 to host 210.242.163.56 left intact

And faulcode and faultstring is :

<faultcode>soap:Client</faultcode>
<faultstring>The server could not recognize the value of the HTTP header SOAPAction: http://210.242.163.56/SendDigXml/GetLastMod/.</faultstring>

I'm using the curlPerform function in the RCurl Package, with the following code:

library(RCurl)
id ="iamuser"
pw ="letmepass"

headerFields =
 c(Accept = "text/xml",
Accept = "multipart/*",
'Content-Type' = "text/xml; charset=utf-8",
SOAPAction = "http://210.242.163.56/SendDigXml/GetLastMod")

body = sprintf('<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetLastMod xmlns="http://210.242.163.56/SendDigXml/">
<user_id>%s</user_id>
<password>%s</password>
<county_code>%s</county_code>
<data_type>%s</data_type>
</GetLastMod>
</soap:Body></soap:Envelope>',id,pw,"Y","1") 

reader = basicTextGatherer()

getupdate<-curlPerform(url = "http://210.242.163.56/SendDigXml/",
                   httpheader = headerFields,
                   postfields = body,
                   writefunction = reader$update,
                   verbose = TRUE)

SOAPAction value format is in accordance with the provisions of the template, and also tried several other representation, but the results are the same. I do not know what else I can try. Can someone help me?

Thank you for your time.

1

1 Answers

0
votes

OK,I find out what's wrong.

SOAPAction should be "http://tempuri.org/GetLastMod" ,not "http://210.242.163.56/SendDigXml/GetLastMod".

and <GetLastMod xmlns="http://210.242.163.56/SendDigXml/"> should be <GetLastMod xmlns="http://tempuri.org/">

Just the same with sample code on the http://210.242.163.56/SendDigXml .

I think this is a mistake that any trained programmer will not make it.but I am not trained programer...I will keep this question instead to delete it. I hope it can help someone like me.