PHP に SOAP Web サービスがあり、それを Objective-C から使用しようとしていますが、応答がありません
リクエストは大丈夫ですか?Webサービスは正常に動作しているようです..
ここにphpの私のコードがあります
<?php
require_once('lib/nusoap.php'); //include required class for build nnusoap web service server
// Create server object
$server = new soap_server();
// configure WSDL
$server->configureWSDL('Upload File', 'urn:uploadwsdl');
// Register the method to expose
$server->register('cadastraUsuario');
// Define the method as a PHP function
function cadastraUsuario($_name, $_surname, $_location, $_email, $_password, $_gender, $_foto, $_tipo, $_dateLogin) {
echo "tetdta";
if($_name and $_surname)
{
$name = strip_tags(trim(htmlentities($_name)));
$surname = strip_tags(trim(htmlentities($_surname)));
$location = strip_tags(trim(htmlentities($_location)));
$email = strip_tags(trim(htmlentities($_email)));
$password = strip_tags(trim(htmlentities($_password)));
$gender = strip_tags(trim(htmlentities($_gender)));
$tipo = strip_tags(trim(htmlentities($_tipo)));
$_foto = $_foto;
//Consulta o email para ver se ja esta cadastrado
$sql_consulta = "select * from `cdusers` where email = '".$email."'";
$result_consulta = mysql_query($sql_consulta);
$row = mysql_num_rows($result_consulta);
header('Content-type: text/xml');
if($row > 0)
{
print'
<resultado>
<mensagem_cadastro>Este e-mail ja esta cadastrado!</mensagem_cadastro>
</resultado>
';
}
else
{
$sql = "INSERT INTO `CDUsers` (`name`, `surname`, `location`, `email`, `password`, `gender`, `foto`, `tipo`, `dateLogin`)
VALUES ('$name', '$surname', '$location', '$email', '$password', '$gender', '$foto', '$tipo', '')";
$result = mysql_query($sql);
//Se a execucao no banco estiver ok ou nao
if($result)
{
print '
<resultado>
<mensagem_cadastro>Usuário Cadastrado com sucesso!</mensagem_cadastro>
</resultado>
';
}
else
print '
<resultado>
<mensagem_cadastro>Erro ao cadastrar o ususario!</mensagem_cadastro>
</resultado>
';
}
}
else
{
echo "nao entrou na condição";
}
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
そして、ここでObjective-Cの私のコード
NSString *soapMessage = [NSString stringWithFormat:@"<SOAP-ENV:Envelope xmlns:SOAP-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:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"; SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">";
"<SOAP-ENV:Body>\n"
"<cadastraUsuarioRequest>"
"<name>%@</name>"
"<surname>%@</surname>"
"<location>%@</location>"
"<email>%@</email>"
"<password>%@</password>"
"<gender>%@</gender>"
"<foto>%@</foto>"
"<tipo>m</tipo>"
"<dateLogin></dateLogin>"
"</cadastraUsuarioRequest>"
"</SOAP-ENV:Body>"
"</SOAP-ENV:Envelope>",txtName.text, txtSurName.text, txtLocation.text, txtEmail.text, txtPassword.text,gender,foto];
NSLog(soapMessage);
NSString *enderecoWS = @"http://www.url.it/cms/soap/server.php";
NSURL *url = [NSURL URLWithString:enderecoWS];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://www.url.it/cms/soap/server.php/cadastraUsuario"; forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if( theConnection )
{
if(!webData)
webData = [[NSMutableData data] retain];
}
else
{
//NSLog(@"theConnection is NULL");
}
}
Web サービスの詳細からのメソッド:
近い
名前: cadastraUsuario バインディング: WebServiceBinding エンドポイント:
http://www.url.it/cms/soap/server.php SoapAction:
http://www.url.it/cms/soap/server.php/cadastraUsuario スタイル: rpc
入力: 使用: エンコードされた名前空間: encodingStyle:
http://schemas.xmlsoap.org/soap/encoding/ メッセージ:
cadastraUsuarioRequest パーツ: 出力: 使用: エンコードされた名前空間:
encodingStyle: http://schemas.xmlsoap.org/soap/encoding/ メッセージ:
cadastraUsuarioResponse パーツ: 名前空間: トランスポート: