2013-03-01 2 views
0

제목에 WCF 서비스가 Windows 서비스로 호스팅되어 있음을 나타냅니다. Visual Studio WCFTestClient를 사용하면 GetVersion() 메서드 (문자열 만 반환 함)가 제대로 작동합니다. 자바 클라이언트에서 같은 메소드를 호출하려고하면 잘못된 호스트 이름 오류가 발생합니다.Windows 호스팅 WCF 서비스가 400 잘못된 요청을 반환합니다 잘못된 호스트 이름을 JAVA 클라이언트로

와이어 샤크 내가 다음 XML 메시지를 추적하고있어 사용 : ------- 보낸

---------

POST /CommunicatorService.svc HTTP/1.1 
Accept: text/xml, multipart/related 
Content-Type: text/xml; charset=utf-8 
SOAPAction: "http://tempuri.org/ICommunicatorService/GetVersion" 

User-Agent: JAX-WS RI 2.2.4-b01 
Host: 192.168.201.210:7770 
Connection: keep-alive 
Content-Length: 373 

<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><GetVersion xmlns="http://tempuri.org/" xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns3="http://schemas.datacontract.org/2004/07/DieboldEras.WorkflowContracts" xmlns:ns4="http://schemas.microsoft.com/2003/10/Serialization/"/></S:Body></S:Envelope> 

을 ------ 응답 ------------

HTTP/1.1 400 Bad Request 
Content-Type: text/html 
Date: Fri, 01 Mar 2013 20:51:18 GMT 

Connection: close 
Content-Length: 39 

<h1>Bad Request (Invalid Hostname)</h1> 


나는 S를 사용하여 호스트 매개 변수와 함께 놀았습니다 erver의 전체 DNS 이름은 같지만 결과는 같습니다. ------

<?xml version="1.0"?> 
<configuration> 
    <system.serviceModel> 
    <services> 
     <service name="DieboldEras.ImagewayCommunicator.Components.CommunicatorService" behaviorConfiguration="DieboldEras.ImagewayCommunicator.Components.CommunicatorServiceBehavior"> 
     <endpoint binding="basicHttpBinding" 
      bindingConfiguration="basicHttpBinding" name="basicHttp" bindingName="basicHttpBinding" 
      contract="DieboldEras.ImagewayCommunicator.Components.ICommunicatorService" > 
     </endpoint> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://192.168.201.210:7770/CommunicatorService" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="DieboldEras.ImagewayCommunicator.Components.CommunicatorServiceBehavior"> 
      <!-- 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="False" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="wsHTTPBinding"/> 
     </wsHttpBinding> 
     <mexHttpBinding> 
     <binding name="mexHTTPBinding"/> 
     </mexHttpBinding> 
     <basicHttpBinding> 
    <binding name="basicHttpBinding" /> 
     </basicHttpBinding> 
    </bindings> 
    <client /> 
    </system.serviceModel> 
    <startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> 
    </startup> 
</configuration> 
내가 자바 클라이언트에 대한 넷빈즈를 사용하고

----- 구성

및 코드는 정직 : :이 설정 파일입니다

- ----- Java 코드 --------

CommunicatorService service = new CommunicatorService(); 
ICommunicatorService port = service.getBasicHttp(); 
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://192.168.201.210:7770/CommunicatorService.svc"); 
String version = port.getVersion(); 

모든 포인터/디버깅 트릭이 도움이됩니다. 나는 Java에 익숙하지 않아서 어디서부터 시작해야할지 모르겠다.하지만 메시지를 보내는 것이 잘못되었다고 생각하고, 서비스의 메시지 나 설정을 바꿔 무엇을 기대해야하는지 알 수있다. 그게 뭔지 모르겠습니다.

미리 감사드립니다.

+0

WCF가 아닌 네트워크 문제인 것으로 보입니다. 다른 컴퓨터에서 Java 코드를 실행하고 있습니까? 네트워크 및 IIS 설정을 확인하십시오. –

답변

3

문제는 자바 코드에서 실제로이었다

CommunicatorService service = new CommunicatorService(); 
ICommunicatorService port = service.getBasicHttp(); 
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://192.168.201.210:7770/CommunicatorService.svc"); 
String version = port.getVersion(); 

실제로 3 글자 만들 어떤 차이

CommunicatorService service = new CommunicatorService(); 
ICommunicatorService port = service.getBasicHttp(); 
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://192.168.201.210:7770/CommunicatorService"); 
String version = port.getVersion(); 

해야합니다!

도움 주셔서 감사합니다 NileshKRathod.

0

<system.serviceModel> 
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
<services> 
    <service name="VInfotech.Server.Intranet.IntranetService" behaviorConfiguration="IntranetService.Service1Behavior"> 
    <!-- Service Endpoints --> 
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="Binding1" contract="VInfotech.Server.Intranet.IIntranet"> 
     <!-- 
      Upon deployment, the following identity element should be removed or replaced to reflect the 
      identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
      automatically. 
     --> 
     <identity> 
     <dns value="localhost"/> 
     </identity> 
    </endpoint> 
    </service> 
    <service name="VInfotech.Server.Intranet.MobileServicesController" behaviorConfiguration="ServBehave"> 
    <endpoint address="RestService" bindingConfiguration="StreamedRequestWebBinding" binding="webHttpBinding" behaviorConfiguration="restPoxBehavior" contract="VInfotech.Server.Intranet.IMobileServices" /> 
    </service> 
</services> 
<bindings> 
    <webHttpBinding> 
    <binding name="StreamedRequestWebBinding" 
    bypassProxyOnLocal="true" 
      useDefaultWebProxy="false" 
      hostNameComparisonMode="WeakWildcard" 
      sendTimeout="10:15:00" 
      openTimeout="10:15:00" 
      receiveTimeout="10:15:00" 
      maxReceivedMessageSize="9223372036854775807" 
      maxBufferPoolSize="9223372036854775807" 
      maxBufferSize="2147483647" 
      transferMode="StreamedRequest" > 
     <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" /> 
    </binding> 
    </webHttpBinding> 
    <basicHttpBinding> 
    <binding name="Binding1" closeTimeout="04:01:00" openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1073741824" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="1073741824" maxStringContentLength="1073741824" maxArrayLength="1073741824" maxBytesPerRead="1073741824" maxNameTableCharCount="1073741824"/> 
    </binding> 
    <!-- For Cyber Source bindings--> 
    <binding name="ITransactionProcessor" closeTimeout="04:01:00" openTimeout="04:01:00" receiveTimeout="04:10:00" sendTimeout="04:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1073741824" maxBufferPoolSize="1073741824" maxReceivedMessageSize="1073741824" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> 
     <readerQuotas maxDepth="1073741824" maxStringContentLength="1073741824" maxArrayLength="1073741824" maxBytesPerRead="1073741824" maxNameTableCharCount="1073741824"/> 
     <security mode="TransportWithMessageCredential"> 
     <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
     <message clientCredentialType="UserName" algorithmSuite="Default"/> 
     </security> 
    </binding> 
    </basicHttpBinding> 
    <!--Cyber Source bindings ends here--> 
</bindings> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="IntranetService.Service1Behavior"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    <behavior name=""> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
    </behavior> 
    <behavior name="ServBehave"> 
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="false" /> 
    </behavior> 
    </serviceBehaviors> 
    <endpointBehaviors> 
    <!--Behavior for the REST endpoint for Help enability--> 
    <behavior name="restPoxBehavior"> 
     <webHttp helpEnabled="true" /> 
    </behavior> 
    <behavior name="jsonBehavior"> 
     <enableWebScript /> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
<client> 
    <endpoint address="https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor" binding="basicHttpBinding" bindingConfiguration="ITransactionProcessor" contract="ITransactionProcessor" name="portXML"/> 
</client> 
<diagnostics> 
    <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" maxSizeOfMessageToLog="2000"/> 
</diagnostics> 

내가이 당신을 도움이되기를 바랍니다 ... 그것은 당신을 도울 수, 서비스 모델 코드이보십시오. :)

관련 문제