Cocoa touch iOS中的ndfdsoap请求
我正在尝试使用SOAP请求从国家数字预报数据库()访问每日天气。SOAP URL是Cocoa touch iOS中的ndfdsoap请求,cocoa-touch,soap,request,ndfd,Cocoa Touch,Soap,Request,Ndfd,我正在尝试使用SOAP请求从国家数字预报数据库()访问每日天气。SOAP URL是 http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php NDFDgenByDay()的Soap操作是 http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#NDFDgenByDay. 当我发送请求时,我收到的xml表明发生了错误,我相信这与我的HTTP头有关。错误响应如下所示
http://graphical.weather.gov/xml/SOAP_server/ndfdXMLserver.php
NDFDgenByDay()
的Soap操作是
http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#NDFDgenByDay.
当我发送请求时,我收到的xml表明发生了错误,我相信这与我的HTTP头有关。错误响应如下所示
<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP- ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
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/">
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">SERVER</faultcode> <faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">format needs to be either 24 hourly or 12 hourly</faultstring><detail xsi:type="xsd:string">input format was ""</detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
其中soapRequest.xml看起来像
<SOAP-ENV:Envelope 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/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns6244:NDFDgenByDay xmlns:ns6244="uri:DWMLgenByDay">
<latitude xsi:type="xsd:string">38.99</latitude>
<longitude xsi:type="xsd:string">-77.01</longitude>
<startDate xsi:type="xsd:string">2012-03-12</startDate>
<numDays xsi:type="xsd:string">7</numDays>
<format xsi:type="xsd:string">24 hourly</format>
</ns6244:NDFDgenByDay>
</SOAP-ENV:Body>
38.99
-77.01
2012-03-12
7.
24小时
我相信soapRequest.xml是正确的,因为它发布在NDFD网站上。但是,我不知道设置HTTP头的正确方法。如果有人对此很熟悉或知道问题所在,请帮助我解决 我通过将soapRequest.xml更改为ff使您的程序正常工作:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 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/">
<SOAP-ENV:Body>
<ns6244:NDFDgenByDay xmlns:ns6244="uri:DWMLgenByDay">
<latitude xsi:type="xsd:decimal">38.99</latitude>
<longitude xsi:type="xsd:decimal">-77.01</longitude>
<startDate xsi:type="xsd:date">2012-08-07</startDate>
<numDays xsi:type="xsd:integer">7</numDays>
<Unit xsi:type="xsd:string">m</Unit>
<format xsi:type="xsd:string">24 hourly</format>
</ns6244:NDFDgenByDay>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
38.99
-77.01
2012-08-07
7.
M
24小时
我通过将soapRequest.xml更改为ff使您的程序正常工作:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 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/">
<SOAP-ENV:Body>
<ns6244:NDFDgenByDay xmlns:ns6244="uri:DWMLgenByDay">
<latitude xsi:type="xsd:decimal">38.99</latitude>
<longitude xsi:type="xsd:decimal">-77.01</longitude>
<startDate xsi:type="xsd:date">2012-08-07</startDate>
<numDays xsi:type="xsd:integer">7</numDays>
<Unit xsi:type="xsd:string">m</Unit>
<format xsi:type="xsd:string">24 hourly</format>
</ns6244:NDFDgenByDay>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
38.99
-77.01
2012-08-07
7.
M
24小时
我自己也在学习SOAP,你的代码帮助我度过了难关,所以多亏了你,codecarrigandBugging,我首先在格式化之后添加了单元。我得到了一个不同的错误,它说'm'是一个错误的格式。所以我知道它读的是单元的内容,不像以前,它说“是错误的格式”。所以我把单位字段移到了格式上面,就这样开始工作了。我花了8个多小时才让SOAP在iOS上运行。我在第7个小时看到了你的代码。顺便问一下,你用什么来解析返回的XML?我使用的是raptureXML,非常棒。据我回忆,我只是使用了NSXMLParser或其他基于委托的解析器。rapture XML似乎使这一可怕的过程变得更加简单…感谢您的提示!将raptureXML添加到我最近的项目中…这是解析XML的好方法!我自己也在学习SOAP,您的代码帮助我克服了困难,所以多亏了您,CodeCarriganDebugging它,我首先在格式之后添加了单元。我得到了一个不同的错误,它说'm'是一个错误的格式。所以我知道它读的是单元的内容,不像以前,它说“是错误的格式”。所以我把单位字段移到了格式上面,就这样开始工作了。我花了8个多小时才让SOAP在iOS上运行。我在第7个小时看到了你的代码。顺便问一下,你用什么来解析返回的XML?我使用的是raptureXML,非常棒。据我回忆,我只是使用了NSXMLParser或其他基于委托的解析器。rapture XML似乎使这一可怕的过程变得更加简单…感谢您的提示!将raptureXML添加到我最近的项目中…这是解析XML的好方法!