powered by simpleCommunicator - 2.0.41     © 2025 Programmizd 02
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / svcutil.exe не может сгенерировать прокси
3 сообщений из 3, страница 1 из 1
svcutil.exe не может сгенерировать прокси
    #38655197
INFINITs
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Добрый день, разбираюсь с WCF.

На IIS разместил сервис.

Конфиг

Код: c#
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.
<?xml version="1.0" encoding="utf-8" ?> 
<configuration>
<system.web>
   <identity impersonate="false"/>
   <compilation debug="true" />
   <httpRuntime maxRequestLength="2147483647" executionTimeout="360000"/>
</system.web>
<system.serviceModel> 
<services> 
	<service  name="TransportModuleService.TModuleServ" behaviorConfiguration="TransportModuleServiceBehavior">
		<endpoint address="" 
			      binding="wsHttpBinding" 
				  contract="TransportModuleService.IServiceTransportModule" />
		<endpoint address="mex"
				  binding="mexHttpBinding"
				  contract="IMetadataExchange" />
	</service> 
</services>
<behaviors>
	<serviceBehaviors>
		<behavior name="TransportModuleServiceBehavior" >
			<serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/>
		</behavior>
	</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>



Сам сервис
Код: c#
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.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.IO;
using System.Data;
using System.Xml;
using System.Text.RegularExpressions;


namespace TransportModuleService
{
    [ServiceContract]
    public interface IServiceTransportModule
    {
        [OperationContract]
        bool ValidateAddress(string emailAddress);
    }

    public class TModuleServ : IServiceTransportModule
    {
        public bool ValidateAddress(string emailAddress)
        {
            string pattern = @"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$";
            return Regex.IsMatch(emailAddress, pattern);
        }
     }
}



Все простое, при обращении к http://localhost:81/TMHoste/service.svc

You have created a service.
To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
svcutil.exe http://localhost:81/TMHoste/service.svc?wsdl

Пытаюсь выполнить данную команду для генерации конфига и прокси класса для клиента и тут проблема.
C:\Documents and Settings\user>"C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\SvcUtil.exe" http://localhost:81/TMHoste/service.svc?wsdl

Ошибка:

Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
Copyright (c) Microsoft Corporation. All rights reserved.

Attempting to download metadata from ' http://localhost:81/TMHoste/service.svc?ws
dl' using WS-Metadata Exchange or DISCO.
Microsoft (R) Service Model Metadata Tool
[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.1]
Copyright (c) Microsoft Corporation. All rights reserved.

Error: Cannot obtain Metadata from http://localhost:81/TMHoste/service.svc?wsdl


If this is a Windows (R) Communication Foundation service to which you have acce
ss, please check that you have enabled metadata publishing at the specified addr
ess. For help enabling metadata publishing, please refer to the MSDN documentat
ion at http://go.microsoft.com/fwlink/?LinkId=65455.


WS-Metadata Exchange Error
URI: http://localhost:81/TMHoste/service.svc?wsdl

Metadata contains a reference that cannot be resolved: ' http://localhost:81/
TMHoste/service.svc?wsdl'.

<?xml version="1.0" encoding="utf-16"?><Fault xmlns=" http://www.w3.org/2003/
05/soap-envelope"><Code><Value>Sender</Value><Subcode><Value xmlns:a=" http://sch
emas.xmlsoap.org/ws/2005/02/sc">a:BadContextToken</Value></Subcode></Code><Reaso
n><Text xml:lang="ru-RU">The message could not be processed. This is most likely
because the action 'http://schemas.xmlsoap.org/ws/2004/09/transfer/Get' is inco
rrect or because the message contains an invalid or expired security context tok
en or because there is a mismatch between bindings. The security context token w
ould be invalid if the service aborted the channel due to inactivity. To prevent
the service from aborting idle sessions prematurely increase the Receive timeou
t on the service endpoint's binding.</Text></Reason></Fault>


HTTP GET Error
URI: http://localhost:81/TMHoste/service.svc?wsdl

The document was understood, but it could not be processed.
- The WSDL document contains links that could not be resolved.
- There was an error downloading 'http://localhost:81/TMHoste/service.svc?xsd=xsd0'.
- The underlying connection was closed: An unexpected error occurred on a rece
ive.
- Unable to read data from the transport connection: An existing connection wa
s forcibly closed by the remote host.
- An existing connection was forcibly closed by the remote host


В чем может быть проблема? И как можно решить?

Проверить сможет ли VS создать прокси класс спомощью Add Reference -возможности нет.
...
Рейтинг: 0 / 0
svcutil.exe не может сгенерировать прокси
    #38656579
INFINITs
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Проблема оказалось простой.

В IIS для сервиса был создан отдельный пул и соответственно заведен был юзер у которого куда-то не хватает прав.
Если же у пула поставить во вкладке Identity - Local System, то все проходит на ура.

Вопрос номер два.
Усложняем сервис, необходимо добавить ссылку на свою библиотеку+появляется в контракте класс из этой библиотеки.
Теперь при обращении к http://localhost:81/TMHoste/service.svc
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'WorkMainDll' could not be found (are you missing a using directive or an assembly reference?)


Насколько понимаю, он не знает ничего про мою библиотеку, как можно это исправить
(библиотека лежит, где и файлик service.cs в App_Code)

Что настроить чтобы при обращении к службе и ее компиляции, она искала библиотеку в своей же папке?

Код: c#
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.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.IO;
using System.Data;
using System.Xml;
using System.Text.RegularExpressions;
using MyDll;

namespace TransportModuleService
{
    [ServiceContract]
    public interface IServiceTransportModule
    {
        [OperationContract]
        bool ValidateAddress(string emailAddress);
    }

    [DataContract]
    public class AboutFileSend
    {
        public AboutFileSend()
        {
            this.err = new WorkMain.ErrorVar();
        }
        [DataMember]
        public int IdFile;
        [DataMember]
        public string FileName;
        [DataMember]
        public string ReplaceFileName;
        [DataMember]
        public string TypeFile;
        [DataMember]
        public WorkMain.ErrorVar err;
    }


    public class TModuleServ : IServiceTransportModule
    {
        public bool ValidateAddress(string emailAddress)
        {
            string pattern = @"^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@(([0-9a-zA-Z])+([-\w]*[0-9a-zA-Z])*\.)+[a-zA-Z]{2,9})$";
            return Regex.IsMatch(emailAddress, pattern);
        }
     }
}
...
Рейтинг: 0 / 0
svcutil.exe не может сгенерировать прокси
    #38656604
INFINITs
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Вопрос снят.
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / svcutil.exe не может сгенерировать прокси
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]