我有我的服务器托管我的WSDL在应用服务器上。我能够访问该服务,并在本地运行我的IP地址时使用这些方法。但是,在我们的应用服务器上运行时,我只能访问WSDL,引用它并查看它的方法,但不能使用这些方法。我将它作为VB.NET 4.0中的控制台应用程序运行。我得到一个InternalServiceFault。无法访问本地主机外部的WSDL
Public Class pokeWCF
Implements poke
Dim objFile As String = "C:\Users\lsj\Documents\Visual Studio 2012\Projects\ConsoleServer\easyA.txt"
Dim aryText() As String
Dim sK As String
Dim fM As String
Dim msg As String
Dim time As DateTime = DateTime.Now
Dim format As String = "ddd d HH:mm yyyy"
Dim OracleReceive As New ReceiveOrcl
Public Function backTo(securityKey As String, from As String, message As String) As ServiceResult Implements poke.backTo
'stuff
End Function
Public Function Test(securityKey As String) As ServiceResult Implements poke.Test
'moreStuff
End Function
End Class
Sub Main()
Dim strHostName As String
Dim strIPAddress As String
strHostName = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()
MsgBox(strIPAddress.ToString)
Dim url As Uri = New Uri("http://" & strIPAddress & ":22380/poke")
Dim host As New ServiceHost(GetType(pokeWCF), url)
Dim smb As New ServiceMetadataBehavior()
Console.WriteLine("CRAB BATTLE!")
Console.Write("Server Up" & vbCrLf)
smb.HttpGetEnabled = True
smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15
host.Description.Behaviors.Add(smb)
host.Open()
Console.WriteLine("Running at " & url.ToString)
Console.Read()
End Sub
查看从应用程序服务器生成的WSDL和我的本地主机的定义有所不同。
编辑:
本地生成WSDL:
<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://tempuri.org/" 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="RacoSMSWCF" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<xs:import namespace="https://t-mobile.racowireless.com/SMSRicochet1.0"/>
<xs:element name="ReceiveSMS">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="securityKey" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="from" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ReceiveSMSResponse">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q1="https://t-mobile.racowireless.com/SMSRicochet1.0" minOccurs="0" name="ReceiveSMSResult" type="q1:ServiceResult"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Test">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="securityKey" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TestResponse">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q2="https://t-mobile.racowireless.com/SMSRicochet1.0" minOccurs="0" name="TestResult" type="q2:ServiceResult"/>
</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>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="https://t-mobile.racowireless.com/SMSRicochet1.0" elementFormDefault="qualified" targetNamespace="https://t-mobile.racowireless.com/SMSRicochet1.0">
<xs:simpleType name="ServiceResult">
<xs:restriction base="xs:string">
<xs:enumeration value="ACCEPTED"/>
<xs:enumeration value="MESSAGE_TOO_LONG"/>
<xs:enumeration value="INVALID_CREDENTIALS"/>
<xs:enumeration value="REJECTED"/>
<xs:enumeration value="NOTFOUND"/>
<xs:enumeration value="INVALID_RECIPIENT"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="ServiceResult" nillable="true" type="tns:ServiceResult"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="racoSMS_ReceiveSMS_InputMessage">
<wsdl:part name="parameters" element="tns:ReceiveSMS"/>
</wsdl:message>
<wsdl:message name="racoSMS_ReceiveSMS_OutputMessage">
<wsdl:part name="parameters" element="tns:ReceiveSMSResponse"/>
</wsdl:message>
<wsdl:message name="racoSMS_Test_InputMessage">
<wsdl:part name="parameters" element="tns:Test"/>
</wsdl:message>
<wsdl:message name="racoSMS_Test_OutputMessage">
<wsdl:part name="parameters" element="tns:TestResponse"/>
</wsdl:message>
<wsdl:portType name="racoSMS">
<wsdl:operation name="ReceiveSMS">
<wsdl:input wsam:Action="http://tempuri.org/racoSMS/ReceiveSMS" message="tns:racoSMS_ReceiveSMS_InputMessage"/>
<wsdl:output wsam:Action="http://tempuri.org/racoSMS/ReceiveSMSResponse" message="tns:racoSMS_ReceiveSMS_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="Test">
<wsdl:input wsam:Action="http://tempuri.org/racoSMS/Test" message="tns:racoSMS_Test_InputMessage"/>
<wsdl:output wsam:Action="http://tempuri.org/racoSMS/TestResponse" message="tns:racoSMS_Test_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_racoSMS" type="tns:racoSMS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ReceiveSMS">
<soap:operation soapAction="http://tempuri.org/racoSMS/ReceiveSMS" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Test">
<soap:operation soapAction="http://tempuri.org/racoSMS/Test" 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="RacoSMSWCF">
<wsdl:port name="BasicHttpBinding_racoSMS" binding="tns:BasicHttpBinding_racoSMS">
<soap:address location="http://192.168.100.88:22380/racoSMS"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
的App Server WSDL:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" name="RacoSMSWCF" targetNamespace="http://tempuri.org/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<xs:import namespace="https://t-mobile.racowireless.com/SMSRicochet1.0"/>
<xs:element name="ReceiveSMS">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="securityKey" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="from" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ReceiveSMSResponse">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q1="https://t-mobile.racowireless.com/SMSRicochet1.0" minOccurs="0" name="ReceiveSMSResult" type="q1:ServiceResult"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Test">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="securityKey" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TestResponse">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q2="https://t-mobile.racowireless.com/SMSRicochet1.0" minOccurs="0" name="TestResult" type="q2:ServiceResult"/>
</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>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="https://t-mobile.racowireless.com/SMSRicochet1.0" elementFormDefault="qualified" targetNamespace="https://t-mobile.racowireless.com/SMSRicochet1.0">
<xs:simpleType name="ServiceResult">
<xs:restriction base="xs:string">
<xs:enumeration value="ACCEPTED"/>
<xs:enumeration value="MESSAGE_TOO_LONG"/>
<xs:enumeration value="INVALID_CREDENTIALS"/>
<xs:enumeration value="REJECTED"/>
<xs:enumeration value="NOTFOUND"/>
<xs:enumeration value="INVALID_RECIPIENT"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="ServiceResult" nillable="true" type="tns:ServiceResult"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="racoSMS_ReceiveSMS_InputMessage">
<wsdl:part name="parameters" element="tns:ReceiveSMS"/>
</wsdl:message>
<wsdl:message name="racoSMS_ReceiveSMS_OutputMessage">
<wsdl:part name="parameters" element="tns:ReceiveSMSResponse"/>
</wsdl:message>
<wsdl:message name="racoSMS_Test_InputMessage">
<wsdl:part name="parameters" element="tns:Test"/>
</wsdl:message>
<wsdl:message name="racoSMS_Test_OutputMessage">
<wsdl:part name="parameters" element="tns:TestResponse"/>
</wsdl:message>
<wsdl:portType name="racoSMS">
<wsdl:operation name="ReceiveSMS">
<wsdl:input wsam:Action="http://tempuri.org/racoSMS/ReceiveSMS" message="tns:racoSMS_ReceiveSMS_InputMessage"/>
<wsdl:output wsam:Action="http://tempuri.org/racoSMS/ReceiveSMSResponse" message="tns:racoSMS_ReceiveSMS_OutputMessage"/>
</wsdl:operation>
<wsdl:operation name="Test">
<wsdl:input wsam:Action="http://tempuri.org/racoSMS/Test" message="tns:racoSMS_Test_InputMessage"/>
<wsdl:output wsam:Action="http://tempuri.org/racoSMS/TestResponse" message="tns:racoSMS_Test_OutputMessage"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_racoSMS" type="tns:racoSMS">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="ReceiveSMS">
<soap:operation soapAction="http://tempuri.org/racoSMS/ReceiveSMS" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Test">
<soap:operation soapAction="http://tempuri.org/racoSMS/Test" 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="RacoSMSWCF">
<wsdl:port name="BasicHttpBinding_racoSMS" binding="tns:BasicHttpBinding_racoSMS">
<soap:address location="http://192.168.200.27:22380/racoSMS"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
编辑:
在发现WCF测试客户端从我得到的测试后,这个错误我的服务在服务器上运行。
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at racoSMS.Test(String securityKey)
at racoSMSClient.Test(String securityKey)
您是否也可以发布您在客户端使用服务的代码? – 2012-08-20 14:24:58
我一直在使用soapUI来使用服务。我们有一个提供商应该连接到我们的服务器,所以我不确定他们是如何实现它的。我试图首先清除我的一切。 – GoodBoyNYC 2012-08-20 14:34:58
在下面发布一个解决方案可以解决您的问题。 – 2012-08-20 15:32:47