Форум программистов, компьютерный форум, киберфорум
C#: Веб-сервисы и WCF
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.63/8: Рейтинг темы: голосов - 8, средняя оценка - 4.63
2 / 2 / 0
Регистрация: 24.02.2013
Сообщений: 62
1
.NET 4.x

Не вызывает WebGet функцию из браузера

27.08.2015, 09:35. Показов 1547. Ответов 3
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Есть веб-сервис с неким функционалом. Для подключения к нему используется как 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>


Подскажите, в чем может быть трабл. Уже всю голову сломал и гугл до дыр протер, сроки поджимают.
0
Лучшие ответы (1)
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
27.08.2015, 09:35
Ответы с готовыми решениями:

Написать функцию, которая, в зависимости от выбора пользователя вызывает соответствующую функцию
Помогите, что то я не могу понять задачи, даже не знаю с чего начать)))) 5. Написать функцию,...

Написать функцию, которая, в зависимости от выбора пользователя вызывает функцию сложения, произведения
Кто знает как можно решить эту задачу на С++? Написать функцию, которая, в зависимости от выбора...

Одна функция вызывает вторую функцию. Как из второй функции заставить первую функцию вернуть true или false?
при попытке отправить форму посылается аякс запрос. В зависимости от того что он вернёт, форма...

Webget и не только
При открытие новых вкладок браузера, открываются и рекламные вкладки. баннеры webget возникают при...

3
2 / 2 / 3
Регистрация: 06.08.2015
Сообщений: 32
27.08.2015, 10:23 2
Лучший ответ Сообщение было отмечено Nikkilla как решение

Решение

Рекомендую вот эту статью. Мне очень помогла)))
1
2 / 2 / 0
Регистрация: 24.02.2013
Сообщений: 62
27.08.2015, 13:40  [ТС] 3
Спасибо за хороший рабочий пример. Все получилось!
0
2 / 2 / 3
Регистрация: 06.08.2015
Сообщений: 32
27.08.2015, 13:47 4
Всегда пожалуйста))
0
27.08.2015, 13:47
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
27.08.2015, 13:47
Помогаю со студенческими работами здесь

Создать функцию take(gen, x) которая вызывает функцию gen заданное число `x` раз
Создать функцию take(gen, x) которая вызывает функцию gen заданное число `x` раз и возвращает...

setInterval не вызывает функцию
Добрый день. Не могу победить кусок: function gameOn () { timerId =...

Функция вызывает функцию
Доброго времени суток уважаемые форумчане! Прошу помощи!!!! К программе подключается DLL. Одна из...

Код не вызывает функцию
Здравствуйте. Делаю пример этого урока https://code-live.ru/post/first-windows-form/,у меня стоит...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
4
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru