제목에 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에 익숙하지 않아서 어디서부터 시작해야할지 모르겠다.하지만 메시지를 보내는 것이 잘못되었다고 생각하고, 서비스의 메시지 나 설정을 바꿔 무엇을 기대해야하는지 알 수있다. 그게 뭔지 모르겠습니다.
미리 감사드립니다.
WCF가 아닌 네트워크 문제인 것으로 보입니다. 다른 컴퓨터에서 Java 코드를 실행하고 있습니까? 네트워크 및 IIS 설정을 확인하십시오. –