Есть веб-сервис с неким функционалом. Для подключения к нему используется как basicHttpBinding для запросов из клиента, так и webHttpBinding для запросов из браузера.
Но загвоздка вся в том, что из клиента все работает на ура, а из браузера запрос в сервис не приходит и возвращается пустая страница.
Код сервиса:
Кликните здесь для просмотра всего текста
C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| [GeneratedCodeAttribute("System.ServiceModel", WebService.serviceModelVersion)]
[ServiceContractAttribute(Namespace = WebService.serviceNamespace, ConfigurationName = WebService.configName)]
public interface IWebService
{
[OperationContractAttribute(Action = WebService.serviceNamespace + "/Echo", ReplyAction = WebService.serviceNamespace + "/EchoResponse")]
[WebGetAttribute(UriTemplate = WebService.serviceNamespace + "/Echo/{message}", BodyStyle = WebMessageBodyStyle.Bare)]
string Echo(string message);
}
[GeneratedCodeAttribute("System.ServiceModel", WebService.serviceModelVersion)]
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
public class WebService : IWebService
{
public const string serviceNamespace = "http://localhost:8080/WebService"; //Remote service namespace
public const string configName = "IWebService"; //Interface name
public const string serviceModelVersion = "4.0.0.0"; //Version of service model
public string Echo(string message)
{
Utility.WriteLine("On Echo: " + message);
return "Echo, " + message;
}
} |
|
Код Web.config
Кликните здесь для просмотра всего текста
XML |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| <?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="srv">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="srv" name="WebService">
<endpoint address="/WebService.svc" binding="basicHttpBinding" contract="IWebService"/>
<endpoint address="" binding="webHttpBinding" contract="IWebService" behaviorConfiguration="web"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration> |
|
Код WebService.svc
Кликните здесь для просмотра всего текста
<%@ServiceHost language="c#" Debug="true" Service="WebService" %>
При открытии описания службы по ссылке "http://localhost:8080/WebService?singleWsdl" нету ни слова про webHttpBinding
Кликните здесь для просмотра всего текста
XML |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
| <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://localhost:8080/WebService" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="WebService" targetNamespace="http://localhost:8080/WebService">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://localhost:8080/WebService">
<xs:element name="Echo">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="EchoResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="EchoResult" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/">
<xs:element name="anyType" nillable="true" type="xs:anyType"/>
<xs:element name="anyURI" nillable="true" type="xs:anyURI"/>
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary"/>
<xs:element name="boolean" nillable="true" type="xs:boolean"/>
<xs:element name="byte" nillable="true" type="xs:byte"/>
<xs:element name="dateTime" nillable="true" type="xs:dateTime"/>
<xs:element name="decimal" nillable="true" type="xs:decimal"/>
<xs:element name="double" nillable="true" type="xs:double"/>
<xs:element name="float" nillable="true" type="xs:float"/>
<xs:element name="int" nillable="true" type="xs:int"/>
<xs:element name="long" nillable="true" type="xs:long"/>
<xs:element name="QName" nillable="true" type="xs:QName"/>
<xs:element name="short" nillable="true" type="xs:short"/>
<xs:element name="string" nillable="true" type="xs:string"/>
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte"/>
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt"/>
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong"/>
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort"/>
<xs:element name="char" nillable="true" type="tns:char"/>
<xs:simpleType name="char">
<xs:restriction base="xs:int"/>
</xs:simpleType>
<xs:element name="duration" nillable="true" type="tns:duration"/>
<xs:simpleType name="duration">
<xs:restriction base="xs:duration">
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?"/>
<xs:minInclusive value="-P10675199DT2H48M5.4775808S"/>
<xs:maxInclusive value="P10675199DT2H48M5.4775807S"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="guid" nillable="true" type="tns:guid"/>
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="FactoryType" type="xs:QName"/>
<xs:attribute name="Id" type="xs:ID"/>
<xs:attribute name="Ref" type="xs:IDREF"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="IWebService_Echo_InputMessage">
<wsdl:part name="parameters" element="tns:Echo"/>
</wsdl:message>
<wsdl:message name="IWebService_Echo_OutputMessage">
<wsdl:part name="parameters" element="tns:EchoResponse"/>
</wsdl:message>
<wsdl:portType name="IWebService">
<wsdl:operation name="Echo">
<wsdl:input wsam:Action="http://localhost:8080/WebService/Echo" message="tns:IWebService_Echo_InputMessage"/>
<wsdl:output wsam:Action="http://localhost:8080/WebService/EchoResponse" message="tns:IWebService_Echo_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IWebService" type="tns:IWebService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Echo">
<soap:operation soapAction="http://localhost:8080/WebService/Echo" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WebService">
<wsdl:port name="BasicHttpBinding_IWebService" binding="tns:BasicHttpBinding_IWebService">
<soap:address location="http://localhost:8080/WebService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions> |
|
Подскажите, в чем может быть трабл. Уже всю голову сломал и гугл до дыр протер, сроки поджимают.