【问题标题】:ASIHTTPRequest SOAP issueASIHTTPRequest SOAP 问题
【发布时间】:2012-08-10 07:20:36
【问题描述】:

请帮我创建 ASIHTTPRequest,它应该发送 xml 数据(soap 请求)。我使用 ASIHTTPRequest 创建通常的请求,但从不使用肥皂。 在我的 iPhone 项目中,我需要发送与我的 Mac 上的其他程序相同的请求。我使用 WireShark 来做到这一点。

这里是wireshark PrintScreens:

获取 Assinded 工作请求(第 1 部分):full image

获取 Assinded 工作请求(第 2 部分):full image

我有创建 ASIHTTPRequest 的经验,但它是 JSON 数据。我了解如何使用正确的标头创建请求。但我不知道如何使用 xml 创建请求。

更新

完整的 xml(对不起 1 个字符串,但 WireShark 以这种方式给我 xml):

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns: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:enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns0="http://com.test/types/AstoriaObjectProperties" xmlns:ns1="http://com.test/wsdl/AstoriaObjectProperties" xmlns:ns2="http://java.sun.com/jax-rpc-ri/internal"><env:Body><ns1:getObjectEnumerationProperties env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><String_1 xsi:type="xsd:string">00000013UF10YZ</String_1><arrayOfString_2 xsi:type="ns0:ArrayOfstring" enc:arrayType="xsd:string[0]" xsi:nil="1"/><HashMap_3 xsi:type="ns2:hashMap" enc:arrayType="ns2:mapEntry[7]"><item xsi:type="ns2:mapEntry"><key xsi:type="xsd:string">ancestorIds</key><value xsi:type="xsd:anyType" xsi:nil="1"/></item><item xsi:type="ns2:mapEntry"><key xsi:type="xsd:string">getAssignedJobs</key><value xsi:type="xsd:anyType" xsi:nil="1"/></item><item xsi:type="ns2:mapEntry"><key xsi:type="xsd:string">description</key><value xsi:type="xsd:anyType" xsi:nil="1"/></item><item xsi:type="ns2:mapEntry"><key xsi:type="xsd:string">name</key><value xsi:type="xsd:anyType" xsi:nil="1"/></item><item xsi:type="ns2:mapEntry"><key xsi:type="xsd:string">custAttrs</key><value xsi:type="enc:boolean">true</value></item><item xsi:type="ns2:mapEntry"><key xsi:type="xsd:string">itemFlavor</key><value xsi:type="xsd:anyType" xsi:nil="1"/></item><item xsi:type="ns2:mapEntry"><key xsi:type="xsd:string">defaultProperties</key><value xsi:type="xsd:anyType" xsi:nil="1"/></item></HashMap_3></ns1:getObjectEnumerationProperties></env:Body></env:Envelope>

提前谢谢你。

【问题讨论】:

  • 请添加您目前拥有的代码,并让我们确切知道您遇到的问题。有很多关于在 iOS 上做 SOAP 的教程/问题。

标签: iphone ipad soap asihttprequest asiformdatarequest


【解决方案1】:

我使用了这个代码。有效

NSURL *url2=[NSURL URLWithString:stringForURL2];
self.request2 = [ASIFormDataRequest requestWithURL:url2];
[request2 setRequestMethod:@"POST"];
[request2 setValidatesSecureCertificate:NO];
[request2 addRequestHeader:@"SOAPAction" value:@""];
[request2 addRequestHeader:@"Content-Type" value:@"text/xml"];


NSString *soapMessage = xmlStringGoesHere;


NSMutableData *soapdata = [[[NSMutableData alloc] initWithData:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]] autorelease];

[request2 setPostBody:soapdata];

request2.username = appDelegate.username;
request2.password = appDelegate.password;

[request2 setDelegate:self];
[request2 setTimeOutSeconds:60];
[request2 startAsynchronous];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-06
    相关资源
    最近更新 更多