• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa: How do I send/receive XML within a HTTP connect?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa: How do I send/receive XML within a HTTP connect?


  • Subject: Re: Cocoa: How do I send/receive XML within a HTTP connect?
  • From: email@hidden
  • Date: Fri, 16 May 2008 11:11:14 -0700 (PDT)

I should add...

Does the NSMutableURLRequest actually send the XML data to the server?

Via the NSMutableURLRequest class, I can alter the HTTP Body, etc.
However, I need to send a SOAP/XML envelope & receive a XML response.

I don't see where in the NSNetworking docs that I can send a SOAP/XML to the server.

I'm puzzled.

Ric.


On 05/16/2008 10:59 email@hidden wrote ..
> Hello, I'm having trouble determining the best path to follow.
>
> Here's the schema in a nutshell:
>
> [Mac <---- XML/SOAP -----> Server]
> .. where an HTTP Post connection is created and a post/reply is synchronously generated.
>
> I want to use Cocoa to do the equivalent in Java:
>
>   StreamConnection xmlstream = null;
>   HttpConnection connection = null;
> xmlstream = (StreamConnection)Connector.open(SOAP_SERVER_URL + ";deviceside=false",Connector.READ_WRITE,true);
>    ...
>    OutputStream out = connection.openOutputStream();  // HttpConnection class.
>    out.write(xmlreq.getBytes()); // Note: 'xmlreq' is type String.
>     ...
>      // ---- Get Response -----
>      // Get the connection status
>      status = connection.getResponseCode();  // HttpConnection class.
>
> ------------------------------
>
> Specifically, I need to:
> 1) Open a read/write connection to a WSDL Soap server.    <-- using NSURLConnection?
> 2) Change Request Properties & Methods to reflect a POST connection.  <-- using
> NSMutableURLRequest?
> 3) Send a XML (SOAP envelope) to the Server; and   <-- ? inside NSURLConnection?
> 4) Get a XML response.    <-- via NSURLConnection?
>
> This is a SYNCHRONOUS, HTTP (POST) connection.
>
> ====================
>
> Here's my dilemma:
> 1) I thought about using the Core Foundation (CFNetworking) route:
>
>        // Java equivalent: connection.setRequestProperty("Content-Type", "text/xml;
> charset=utf-8");
>
>         CFHTTPMessageSetHeaderFieldValue(myRequest,CFSTR("User-Agent"), CFSTR("Apple
> iPhone"));
>         CFHTTPMessageSetHeaderFieldValue(myRequest,CFSTR("Content-Type"), CFSTR("text/xml;
> charset=utf-8"));
>         CFHTTPMessageSetHeaderFieldValue(myRequest,CFSTR("Accept"), CFSTR("text/html"));
>
> But I don't know how to Synchronously Send/Receive as shown in the Java code, above.
>
>
> 2) If possible, I prefer to use the higher-level NSNetworking scheme: via NSMutableURLRequest.
>      I can modify the request to be POST and I think I can modify the header for
> the Content-Type, etc.
>
>  Do I use NSURLConnection to actually TRANSMIT & RECEIVE XML data to the Server
> like this?
>
>        serverData = [NSURLConnection sendSynchronousRequest:theRequest
>                                     returningResponse:serverResponse
>                                     error:myError];
>
> 3) Then, how do I flush(), close() this connection?
>
> 4) or... must I try the CF route?
>
> Regards,
> Ric.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Cocoa: How do I send/receive XML within a HTTP connect?
      • From: Jens Alfke <email@hidden>
    • Re: Cocoa: How do I send/receive XML within a HTTP connect?
      • From: "stephen joseph butler" <email@hidden>
  • Prev by Date: Re: Cocoa: How do I send/receive XML within a HTTP connect?
  • Next by Date: Re: Guidance for Cocoa's steep learning curve
  • Previous by thread: Re: Cocoa: How do I send/receive XML within a HTTP connect?
  • Next by thread: Re: Cocoa: How do I send/receive XML within a HTTP connect?
  • Index(es):
    • Date
    • Thread