Dobrý den. Moji distributoři používají stejný systém, tzn. i stejné rozhraní webových služeb. Proto mi bylo porazeno (sám bych na to nikdy nepřišel) následující: **************START COPY********************* Vytvoril bych projekt, kde bych referenci na I6WS zadal jen jednou (ne tedy AbacusWS, 100MegaWS, SWSWS, ....). Rozhrani maji vsechny stejne, takze nejakou obecnou referenci: I6WS Odkud pak stahovat data muzete ridit property .Url a logovaci udaje zadavate pomoci .Credentials Takze napr. pro Abacus nejak takto:
Sub Main()
Dim ws As I6WS.I6WebService = New I6WS.I6WebService()
ws.Url = "http://www.abacus.cz/i6ws/default.asmx"
ws.Credentials = New Net.NetworkCredential("JMENO", "HESLO")
Dim n As System.Xml.XmlNode = ws.GetResultByCode("StoItemQtyFree", "CHS
SKT-0115")
If Not n Is Nothing Then
n = n.SelectSingleNode("StoItem/@QtyFreeIs")
If Not n Is Nothing Then Console.WriteLine(n.Value)
End If
End Sub
Pro jineho distributora s I6kou (- napr.: 100M) jen zamenite: ws.Url = "http://eshop.100mega.cz/i6ws/default.asm..." ws.Credentials = New Net.NetworkCredential("JMENO", "HESLO") vse jinak zustava stejne. **************************KONEC COPY************** Rada je to skvělá a úžasná a mně by posunula dále, jenže VB tvrdí, že v tom:
Dim ws As I6WS.I6WebService = New I6WS.I6WebService()
I6WS.i6WebService není definovaným typem. ("Type I6WS.i6WebService is not defined.") Popravdě řečeno, ve jmenném prostoru I6WS opravdu něco jako I6WebService není, IntelliSense mi po I6WS. nabízí jen: I6WebServiceSoapClient I6WebServiceHttpGetClient I6WebServiceHttpPostClient Ale to je asi tím, že jsem referenci na webovou službu uskutečnil pomocí průvodce na skutečnou službu, tudíž mi teď už nabízí jen to, co daná služba poskytuje. Pokud to změním na:
Dim ws As I6WS.I6WebServiceSoap = New I6WS.I6WebServiceHttpPostClient()
ws.Url = "http://www.abacus.cz/i6ws/default.asmx"
ws.Credentials = New Net.NetworkCredential("JMENO", "HESLO")
tak samozřejmě zase neexistují vlastnosti .Url a .Credentials, resp. nejsou členy I6WebServiceSoap. Koukám do Reference.vb a nejsem z toho moudrej:
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:2.0.50727.1433
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
Option Strict On
Option Explicit On
Namespace I6WS
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), _
System.ServiceModel.ServiceContractAttribute(Name:="I6 Web ServiceSoap", [Namespace]:="http://www.cybersoft.cz/I6/Web/WebService/", ConfigurationName:="I6WS.I6WebServiceSoap")> _
Public Interface I6WebServiceSoap
<System.ServiceModel.OperationContractAttribute(Action:="http://www.cybersoft.cz/I6/Web/WebService/HelloWorld", ReplyAction:="*"), _
System.ServiceModel.XmlSerializerFormatAttribute()> _
Function HelloWorld() As String
<System.ServiceModel.OperationContractAttribute(Action:="http://www.cybersoft.cz/I6/Web/WebService/GetResult", ReplyAction:="*"), _
System.ServiceModel.XmlSerializerFormatAttribute()> _
Function GetResult(ByVal resultType As String) As System.Xml.XmlNode
<System.ServiceModel.OperationContractAttribute(Action:="http://www.cybersoft.cz/I6/Web/WebService/GetResultByCode", ReplyAction:="*"), _
System.ServiceModel.XmlSerializerFormatAttribute()> _
Function GetResultByCode(ByVal resultType As String, ByVal code As String) As System.Xml.XmlNode
<System.ServiceModel.OperationContractAttribute(Action:="http://www.cybersoft.cz/I6/Web/WebService/GetResultByFromTo", ReplyAction:="*"), _
System.ServiceModel.XmlSerializerFormatAttribute()> _
Function GetResultByFromTo(ByVal resultType As String, ByVal from As Date, ByVal [to] As Date) As System.Xml.XmlNode
End Interface
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Public Interface I6WebServiceSoapChannel
Inherits I6WS.I6WebServiceSoap, System.ServiceModel.IClientChannel
End Interface
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Partial Public Class I6WebServiceSoapClient
Inherits System.ServiceModel.ClientBase(Of I6WS.I6WebServiceSoap)
Implements I6WS.I6WebServiceSoap
Public Sub New()
MyBase.New
End Sub
Public Sub New(ByVal endpointConfigurationName As String)
MyBase.New(endpointConfigurationName)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(binding, remoteAddress)
End Sub
Public Function HelloWorld() As String Implements I6WS.I6WebServiceSoap.HelloWorld
Return MyBase.Channel.HelloWorld
End Function
Public Function GetResult(ByVal resultType As String) As System.Xml.XmlNode Implements I6WS.I6WebServiceSoap.GetResult
Return MyBase.Channel.GetResult(resultType)
End Function
Public Function GetResultByCode(ByVal resultType As String, ByVal code As String) As System.Xml.XmlNode Implements I6WS.I6WebServiceSoap.GetResultByCode
Return MyBase.Channel.GetResultByCode(resultType, code)
End Function
Public Function GetResultByFromTo(ByVal resultType As String, ByVal from As Date, ByVal [to] As Date) As System.Xml.XmlNode Implements I6WS.I6WebServiceSoap.GetResultByFromTo
Return MyBase.Channel.GetResultByFromTo(resultType, from, [to])
End Function
End Class
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), _
System.ServiceModel.ServiceContractAttribute(Name:="I6 Web ServiceHttpGet", [Namespace]:="http://www.cybersoft.cz/I6/Web/WebService/", ConfigurationName:="I6WS.I6WebServiceHttpGet")> _
Public Interface I6WebServiceHttpGet
<System.ServiceModel.OperationContractAttribute()> _
Sub HelloWorld()
<System.ServiceModel.OperationContractAttribute()> _
Sub GetResult()
<System.ServiceModel.OperationContractAttribute()> _
Sub GetResultByCode()
<System.ServiceModel.OperationContractAttribute()> _
Sub GetResultByFromTo()
End Interface
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Public Interface I6WebServiceHttpGetChannel
Inherits I6WS.I6WebServiceHttpGet, System.ServiceModel.IClientChannel
End Interface
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Partial Public Class I6WebServiceHttpGetClient
Inherits System.ServiceModel.ClientBase(Of I6WS.I6WebServiceHttpGet)
Implements I6WS.I6WebServiceHttpGet
Public Sub New()
MyBase.New
End Sub
Public Sub New(ByVal endpointConfigurationName As String)
MyBase.New(endpointConfigurationName)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(binding, remoteAddress)
End Sub
Public Sub HelloWorld() Implements I6WS.I6WebServiceHttpGet.HelloWorld
MyBase.Channel.HelloWorld
End Sub
Public Sub GetResult() Implements I6WS.I6WebServiceHttpGet.GetResult
MyBase.Channel.GetResult
End Sub
Public Sub GetResultByCode() Implements I6WS.I6WebServiceHttpGet.GetResultByCode
MyBase.Channel.GetResultByCode
End Sub
Public Sub GetResultByFromTo() Implements I6WS.I6WebServiceHttpGet.GetResultByFromTo
MyBase.Channel.GetResultByFromTo
End Sub
End Class
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), _
System.ServiceModel.ServiceContractAttribute(Name:="I6 Web ServiceHttpPost", [Namespace]:="http://www.cybersoft.cz/I6/Web/WebService/", ConfigurationName:="I6WS.I6WebServiceHttpPost")> _
Public Interface I6WebServiceHttpPost
<System.ServiceModel.OperationContractAttribute()> _
Sub HelloWorld()
<System.ServiceModel.OperationContractAttribute()> _
Sub GetResult()
<System.ServiceModel.OperationContractAttribute()> _
Sub GetResultByCode()
<System.ServiceModel.OperationContractAttribute()> _
Sub GetResultByFromTo()
End Interface
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Public Interface I6WebServiceHttpPostChannel
Inherits I6WS.I6WebServiceHttpPost, System.ServiceModel.IClientChannel
End Interface
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Partial Public Class I6WebServiceHttpPostClient
Inherits System.ServiceModel.ClientBase(Of I6WS.I6WebServiceHttpPost)
Implements I6WS.I6WebServiceHttpPost
Public Sub New()
MyBase.New
End Sub
Public Sub New(ByVal endpointConfigurationName As String)
MyBase.New(endpointConfigurationName)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(endpointConfigurationName, remoteAddress)
End Sub
Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
MyBase.New(binding, remoteAddress)
End Sub
Public Sub HelloWorld() Implements I6WS.I6WebServiceHttpPost.HelloWorld
MyBase.Channel.HelloWorld
End Sub
Public Sub GetResult() Implements I6WS.I6WebServiceHttpPost.GetResult
MyBase.Channel.GetResult
End Sub
Public Sub GetResultByCode() Implements I6WS.I6WebServiceHttpPost.GetResultByCode
MyBase.Channel.GetResultByCode
End Sub
Public Sub GetResultByFromTo() Implements I6WS.I6WebServiceHttpPost.GetResultByFromTo
MyBase.Channel.GetResultByFromTo
End Sub
End Class
End Namespace
Čili jsem opět před otázkou, kterak byla myšlena ta "obecná reference" na webovou službu :-(
|