別の Web サービス (AndroidService) から呼び出している Web サービス (LoginService) があります。接続をテストする簡単な方法がありますが、機能していません。
LoginService には getStuff(string password) というメソッドがあります。JSON で文字列を返します。ブラウザから直接アクセスすると、http://localhost/LoginService/LoginService.svc/getStuff/fooで正常に動作します。他の Web サービスを介して同じことを試みると、件名の例外と InnerException "The server returned 404 Not Found" で失敗します。
LoginService の定義は次のとおりです。
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "getStuff/{password}")]
string getStuff(string password);
AndroidService のコードは次のとおりです。
public string getStuff(string password)
{
string endpoint_address = "http://localhost/LoginService/LoginService.svc/";
BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress address = new EndpointAddress(endpoint_address);
client = new LoginServiceClient(binding, address);
return client.getStuff(password);
}
そして AndroidService 定義:
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "getStuff/{password}")]
string getStuff(string password);
完全な例外は次のとおりです。
Request Error
The server encountered an error processing the request. The exception message is 'There was no endpoint listening at http://localhost/LoginService/LoginService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.'. See server logs for more details. The exception stack trace is:
Server stack trace: at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at AndroidServiceSpace.LoginServiceReference.ILoginService.getStuff(String password) at AndroidServiceSpace.LoginServiceReference.LoginServiceClient.getStuff(String password) in C:\AndroidServiceUUS\trunk\services\AndroidService\AndroidService\Service References\LoginServiceReference\Reference.cs:line 264 at AndroidServiceSpace.AndroidService.getStuff(String password) in C:\AndroidServiceUUS\trunk\services\AndroidService\AndroidService\AndroidService.svc.cs:line 77 at SyncInvokegetStuff(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
私のweb.config:
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings >
<webHttpBinding>
<binding name="BasicHttpBinding_UserService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/LoginService/LoginService.svc" binding="webHttpBinding"
bindingConfiguration="BasicHttpBinding_UserService" contract="LoginServiceReference.ILoginService" />
</client>
<services>
<service behaviorConfiguration="AndroidBehaviour" name="AndroidServiceSpace.AndroidService">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
contract="AndroidServiceSpace.IAndroidService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="AndroidBehaviour">
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Fiddler リクエストを取得するためにサーバーを削除するように LoginService を移動しました。
# Result Protocol Host URL Body Caching Content-Type Process Comments Custom
4 502 HTTP 10.0.4.12:50271 /AndroidService.svc/getStuff/ggnore 512 text/html; charset=UTF-8 chrome:4132
5 502 HTTP 10.0.4.12:50271 /favicon.ico 512 text/html; charset=UTF-8 chrome:4132
6 400 HTTP localhost:50271 /AndroidService.svc/getStuff/ggnore 4 565 private text/html chrome:4132
7 404 HTTP localhost:50271 /favicon.ico 2 310 private text/html; charset=utf-8 chrome:4132
8 200 HTTP Tunnel to clients4.google.com:443 0 chrome:4132
9 404 HTTP maker.server /LoginService/LoginService.svc/$metadata 1 565 private text/html; charset=UTF-8 vwdexpress:5772
10 200 HTTP maker.server /LoginService/LoginService.svc 2 790 private text/html; charset=UTF-8 vwdexpress:5772
11 200 HTTP maker.server /LoginService/LoginService.svc/mex 10 195 private application/soap+xml; charset=utf-8 vwdexpress:5772
12 404 HTTP maker.server /LoginService/LoginService.svc 1 565 private text/html; charset=UTF-8 vwdexpress:5772
13 200 HTTP maker.server /LoginService/LoginService.svc?disco 289 private text/xml; charset=UTF-8 vwdexpress:5772
14 200 HTTP maker.server /LoginService/LoginService.svc?wsdl 3 902 private text/xml; charset=UTF-8 vwdexpress:5772
15 200 HTTP maker.server /LoginService/LoginService.svc?xsd=xsd0 1 969 private text/xml; charset=UTF-8 vwdexpress:5772
16 200 HTTP maker.server /LoginService/LoginService.svc?xsd=xsd2 1 521 private text/xml; charset=UTF-8 vwdexpress:5772
17 200 HTTP maker.server /LoginService/LoginService.svc?xsd=xsd1 2 273 private text/xml; charset=UTF-8 vwdexpress:5772
18 200 HTTP localhost:50271 / 2 756 text/html; charset=utf-8 chrome:4132
19 404 HTTP localhost:50271 /favicon.ico 2 310 private text/html; charset=utf-8 chrome:4132
20 400 HTTP localhost:50271 /AndroidService.svc/getStuff/ggnore 4 565 private text/html chrome:4132
21 404 HTTP localhost:50271 /favicon.ico 2 310 private text/html; charset=utf-8 chrome:4132