传递给WSDL生成的代码的空对象

时间:2012-01-16 11:58:10

标签: iphone soap

我使用SOAP服务和WSDL2OBJ工具为我的Web服务生成代码。 我使用以下代码将参数传递给服务但它将Emplty数据包发送到我的服务。

问题是什么?

//以下是我用于在OBJ-C中发送数据包的代码     Qula_x0020_WebServiceSoapBinding * binding = [[Qula_x0020_WebService Qula_x0020_WebServiceSoapBinding] initWithAddress:@“URL”];     binding.logXMLInOut = YES;     // Qula_x0020_WebService_ws_LoginInfo * loginInfo = []

Qula_x0020_WebService_Login *parms = [[Qula_x0020_WebService_Login alloc] init];

[[parms LoginInfo] setEMAIL:@"username"];
[[parms LoginInfo] setPASSWORD:@"pasword"];
[[parms DeviceInfo] setMODEL:@"model"];
[[parms DeviceInfo] setDEVICE_TIME:@"time"];

[binding LoginAsyncUsingParameters:parms delegate:self];

现在这是我的WEBService的XML:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:qula="url/">
   <soap:Header/>
      <soap:Body>
         <qula:Login>
            <qula:LoginInfo>
                <qula:EMAIL>?</qula:EMAIL>
                <qula:PASSWORD>?</qula:PASSWORD>
             </qula:LoginInfo>
             <qula:DeviceInfo>
                 <qula:MODEL>?</qula:MODEL>
                 <qula:DEVICE_TIME>?</qula:DEVICE_TIME>
             </qula:DeviceInfo>
          </qula:Login>
         </soap:Body>
 </soap:Envelope>

我的Obj-C请求生成的XML如下:

 <?xml version="1.0"?>
 <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:Qula_x0020_WebService="http://qula.sigmatec.com.pk/" xsl:version="1.0">
  <soap:Body>
       <Qula_x0020_WebService:Login/>
   </soap:Body>
  </soap:Envelope>

任何人都可以帮我解决问题。 M卡在这里。 :(

1 个答案:

答案 0 :(得分:0)

我将告诉你如何处理数据,当我用肥皂消息发送它时可能会有帮助


NSString *conduitPath = [NSString stringWithFormat:@"http://yourwebservicename",serverIP];


NSURL *url = [NSURL URLWithString:conduitPath];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];


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>"
                     "<registration xmlns=\"http://tempuri.org/\">"
                     "<username>%@</username>"
                     "<password>%@</password>"
                     "<name>%@</name>"
                     "<email>%@</email>"
                     "<mobile>%@</mobile>"
                     "</registration>"
                     "</soap:Body>"
                     "</soap:Envelope>",self.userNameTxt.text,self.passwordTxt.text,self.nameTxt.text,self.emailTxt.text,self.mobileTxt.text];


NSString *msgLength = [NSString stringWithFormat:@"%d",[soapmsg length]];

[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"http://tempuri.org/registration" forHTTPHeaderField:@"SOAPAction"];
[request addValue:msgLength forHTTPHeaderField:@"Content-Length"];


[request setHTTPMethod:@"POST"];
[request setHTTPBody:[soapmsg dataUsingEncoding:NSUTF8StringEncoding]];


conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if(conn)
{
    webData = [[NSMutableData data]retain];

}

之后实现NSURLConnection委托方法以确保连接成功加载。