У меня есть простой веб-сервис asmx.он использовался в нашем старом приложении для Winphone, и теперь я хочу использовать его в новых приложениях.Приложение xamarin.forms на Android работает хорошо.Тесты с локальной веб-страницы работают хорошо.Но с приложением ios / target C я полностью пропустил.
я установил локальный iis (на ноутбуке w10), сервис прекрасно работает из браузера, может быть отлажен и т. Д.
в журналах iis запросы от браузера и приложения похожи, но результат другой
'2019-07-05 09:00:35 fe80::54ae:f86a:269:32ce%14 POST /ws/bcws.asmx/GetCurrencyList - 80 - fe80::54ae:f86a:269:32ce%14 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64;+rv:67.0)+Gecko/20100101+Firefox/67.0 http://ish-xps/ws/bcws.asmx?op=GetCurrencyList 200 0 0 780'
'2019-07-05 09:06:17 192.168.101.159 POST /ws/bcws.asmx/GetCurrencyList - 80 - 192.168.101.137 bc2+IOS+request businesscalc 500 0 0 9'
, когда я подключаюсь к нему с Mac (в той же сети Wi-Fi) или Ipad в той же сети.происходит сбой с исключением (ниже)
Я установил Fiddler в качестве обратного прокси.мое приложение прекрасно работает через Fiddler, но получает исключение от сервера, если я подключаюсь напрямую
Я меняю только одну строку кода
#define SERVER_ADDR @"ish-xps"
на
#define SERVER_ADDR @"ish-xps:8888"
нижеКод запроса
Может быть, кто-то есть идея, что я делаю не так?заранее спасибо ish
-(BOOL) GetCurrencyList
{
soapReq_GetCurrencyList = @" \
<?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> \
<GetCurrencyList xmlns=\"http://ish-xps/ws\" /> \
</soap:Body> \
</soap:Envelope> \
\
";
[self sendToServerWithRequest:soapReq_GetCurrencyList];
return (true);
}
-(BOOL) sendToServerWithRequest:(NSString *)req
{
NSString *connectStr = [NSString stringWithFormat:@"http://%@/ws/bcws.asmx/GetCurrencyList", SERVER_ADDR];
NSURL *serverUrl = [NSURL URLWithString:connectStr];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:serverUrl];
NSString *reqLength = [NSString stringWithFormat:@"%lu", (unsigned long) req.length];
NSString *soapAction = [NSString stringWithFormat:@"http://%@/ws/GetCurrencyList",SERVER_ADDR];
[request addValue:@"bc2 IOS request" forHTTPHeaderField:@"User-Agent"];
[request addValue:SERVER_ADDR forHTTPHeaderField:@"HOST"];
[request addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:reqLength forHTTPHeaderField:@"Content-Length"];
[request addValue:soapAction forHTTPHeaderField:@"SOAPAction"];
[request addValue:@"businesscalc" forHTTPHeaderField:@"Referer"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[req dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connect = [[NSURLConnection alloc]initWithRequest:request delegate:self];
if (connect)
{
return (true);
}
else
{
return (false);
}
}
Server Error in '/ws' Application.
Request format is unrecognized for URL unexpectedly ending in '/GetCurrencyList'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetCurrencyList'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: Request format is unrecognized for URL unexpectedly ending in '/GetCurrencyList'.]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +401372
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +281
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +89
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +564
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +142
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +263