NSArray를 웹 서비스에 보낼 수있는 성공이 없습니다.
서비스 메소드가 호출되지 않습니다. 그러나 다른 서비스 방법은 작업을 호출합니다.
웹 서비스 방법은 다음과 같습니다웹 서비스에 NSArray를 보내는 방법
NSString *soapMsg =
[NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
"<soap:Body>"
"<Method xmlns=\"http://www.mysite.com/\">"
"<items>"
"%@"
"</items>"
"</Method>"
"</soap:Body>"
"</soap:Envelope>", myArray
];
NSURL *url = [NSURL URLWithString: @"http://...."];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://www.mysite.com/Method" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPMethod:@"POST"];
[req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn)
{
webData = [NSMutableData data];
}
:이 같은 데이터를 보내려고 목표 C에서
@interface Item : NSObject
{
double prop1;
double prop2;
double prop3;
}
@property double prop1;
@property double prop2;
@property double prop3;
:
[WebMethod]
public int Method(IList items){...
내 배열에 객체 항목이 가득 업데이트
이 같은 배열 할 때 :
NSArray * myArrDate = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil];
그리고 만들 : 그것은 작동
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:myArrDate
options:0
error:nil];
합니다. 하지만 배열이 User
이고 배열은 UserId, FirstName, LastName, Email, Username, DisplayName, Country, City
등입니다. 배열로 위의 코드를 시도하면 해당 행에 응용 프로그램 충돌이 발생합니다.
같은 왕자 대답. 이 앱을 실행할 때 충돌이 발생합니다. 어떤 오류도없이. – 1110
질문이 업데이트되었습니다. – 1110
좋아, NSJSONSerialization을 사용하려면 동일한 속성을 가진 새로운 클래스를 만들 필요가 있지만 모두 NSString이되어야한다는 것을 알았다. 내가 이것을 할 때 그것은 작동한다. 나는이 대답을 받아 들일 것이다. – 1110