Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mickwaffle

macrumors newbie
Original poster
Jun 14, 2010
6
0
hi, im looking for a bit of help with XML and SOAP.
I am currently sending data to a web server using. I am using WSMethodInvocation. to sete the parameters, I use WSMethodInvocationSetParameters. However, I am now wondering, how can I add atrributes to my parameters. A the moment I can only do this sort of thing: <parameter > Some text</parameter>
However, I am looking to be able to do something like this:
<parameter value="sometext" > Some text</parameter>

thanks
 
im not sure how i would use that... i think thats just used for setting properties of the actual WSMethodInvocation as opposed to the actual parameters.
 
Maybe you could explain what you are trying to do a little bit more clearly. I don't understand why you would have to touch the actual XML message being sent.
 
this is my code:

Code:
// SOAP call settings
	NSURL *url = [NSURL URLWithString:@"http://localhost/Service.asmx"];
	NSString *method = @"myMethod";
	NSString *namespace = @"http://localhost/namespace";
	
	NSDictionary *params = [NSDictionary dictionaryWithObject:@"TEXT VALUE"forKey:@"myParameter"];
	NSArray *paramOrder = [NSArray arrayWithObject:@"myParameter"];
	
	// SOAP call http headers -- some SOAP server impls require even empty SOAPAction headers
	NSDictionary *reqHeaders = [NSDictionary dictionaryWithObject:@"" forKey:@"SOAPAction"]; 
	
	WSMethodInvocationRef soapReq = createSOAPCall(url, method, namespace, params, paramOrder, reqHeaders, soapHeaders);

The function:

WSMethodInvocationRef createSOAPCall(NSURL *url,
                                     NSString *method,
                                     NSString *namespace,
                                     NSDictionary *params,
                                     NSArray *paramOrder,
                                     NSDictionary *reqHeaders)
{
    WSMethodInvocationRef soapReq = WSMethodInvocationCreate((CFURLRef)url,
                                                              (CFStringRef)method,
                                                              kWSSOAP2001Protocol);
	
    
	
    WSMethodInvocationSetParameters(soapReq, (CFDictionaryRef)params, (CFArrayRef)paramOrder);
	
	
	
    // set method namespace
    WSMethodInvocationSetProperty(soapReq, kWSSOAPMethodNamespaceURI, (CFStringRef)namespace);
	
    // Add HTTP headers (with SOAPAction header) -- some SOAP impls require even empty SOAPAction headers
    WSMethodInvocationSetProperty(soapReq, kWSHTTPExtraHeaders, (CFDictionaryRef)reqHeaders);
	
    // for good measure, make the call follow redirects.
    WSMethodInvocationSetProperty(soapReq,    kWSHTTPFollowsRedirects, kCFBooleanTrue);
	
    // set debug props
	
	
    WSMethodInvocationSetProperty(soapReq, kWSDebugIncomingBody,     kCFBooleanTrue);
    WSMethodInvocationSetProperty(soapReq, kWSDebugIncomingHeaders, kCFBooleanTrue);
    WSMethodInvocationSetProperty(soapReq, kWSDebugOutgoingBody,     kCFBooleanTrue);
    WSMethodInvocationSetProperty(soapReq, kWSDebugOutgoingHeaders, kCFBooleanTrue);
	
    return soapReq;
}

I am trying to use apples Web Services to send soap requests to my server. However, instead of having just <myParameter>TEST VALUE</myParameter> in the method body... i need to have <myParameter value="another_value">TEST VALUE</myParameter>
 
I mis-typed. I meant to suggest you use: WSMethodInvocationSetParameters

But it looks like you are already using it. The XML-RPC format does not support what you are trying to do. Generally it is in the format:
...
<params>
<param>
<value> <TYPE>value</TYPE> </value>
<param>
...
</params>

If the web-service you are consuming is not in strict compliance with XML-RPC you may need to use a third party tool.
 
ok, thanks a lot for your help :)
let's say i was to go ahead, and make my xml soap request myself, just as a regular string, what function would i then use to send it off to my webservice?
thanks again
 
That's easier in many cases. Just use amy http transport protocol. It's guaranteed to work over http.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.