iphoneipadsoapasihttprequestasiformdatarequest

ASIHTTPRequest SOAP issue


Please, help me to create ASIHTTPRequest, that should send xml data (soap request). I used ASIHTTPRequest to create usual request, but never soap. In my iPhone project I need to send the request identical to the request, that other program on my Mac does. I use WireShark to do that.

Here are the wireshark PrintScreens:

Get Assinded Jobs Request (part 1): full image

Get Assinded Jobs Request (part 1): Get Assinded Jobs Request (part 2):full image

Get Assinded Jobs Request (part 2):

I have an experience of creating ASIHTTPRequest, but it was JSON data. I understand, how to create request with proper header. But I have no idea, how to create request with xml.

Update

Full xml (sorry for 1 string, but WireShark gives xml to me in that manner ):

<?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>

Thank you in advance.


Solution

  • I used this code. It works

    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];