Accessing existing web service in VB 2008
I have a pre-existing web service that I'm creating a new client reference for. It's been a long while since I worked with web services and I can't get it to work. I'm not sure if it because I'm having a brain fart and overlooking something extremely basic and simple or if there's some new web service functionality in VB 2008 where I have to add some stuff into.
The web service is a simple one called eFulfillmentWebService and has two functions:
Code:
FulfillPolicyXML(fulfillmentRequest as String) as String
OperationStatusXML(status as String) as Boolean
I have it running on my local machine and inside of a VB.NET 2008 client project, I added a service reference to it called TestService.
This created a section with the app.config file as follows:
Code:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="EFulfillmentWebServiceSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:1618/EFulfillmentWebService.asmx"
binding="basicHttpBinding" bindingConfiguration="EFulfillmentWebServiceSoap"
contract="TestService.EFulfillmentWebServiceSoap" name="EFulfillmentWebServiceSoap" />
</client>
</system.serviceModel>
There's also a reference file that was generated which seems to have an interface in it and a bunch of other crap:
Code:
'------------------------------------------------------------------------------
' <auto-generated>
' This code was generated by a tool.
' Runtime Version:2.0.50727.3615
'
' 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 TestService
<System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"), _
System.ServiceModel.ServiceContractAttribute([Namespace]:="http://xxx.xx/services/efulfillment/", ConfigurationName:="TestService.EFulfillmentWebServiceSoap")> _
Public Interface EFulfillmentWebServiceSoap
'CODEGEN: Generating message contract since element name fulfillmentXML from namespace http://xxx.xx/services/efulfillment/ is not marked nillable
<System.ServiceModel.OperationContractAttribute(Action:="http://xxx.xx/services/efulfillment/FulfillPolicyXML", ReplyAction:="*")> _
Function FulfillPolicyXML(ByVal request As TestService.FulfillPolicyXMLRequest) As TestService.FulfillPolicyXMLResponse
'CODEGEN: Generating message contract since element name status from namespace http://xxx.xx/services/efulfillment/ is not marked nillable
<System.ServiceModel.OperationContractAttribute(Action:="http://xxx.xx/services/efulfillment/OperationStatusXML", ReplyAction:="*")> _
Function OperationStatusXML(ByVal request As TestService.OperationStatusXMLRequest) As TestService.OperationStatusXMLResponse
End Interface
...
'A lot of other stuff here which makes it too long to post
End Namespace
Now, I tried making a class which implements the autogenerated code there and I've tried accessing the service directly (which I think is how I remember doing it). Neither of those work. I can go to the endpoint address in the app.config file and all the methods come up and I can type some strings into them and get a valid response, but I can't seem to access any of the methods from within the VB client.
Does anyone have an idea what it is that I'm missing or can point me in the right direction? I have a feeling that I'm just overlooking a simple step two in a basic three step process.
Re: Accessing existing web service in VB 2008
Inside the reference file, it has a class that implements the web service proxy:
Code:
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")> _
Partial Public Class EFulfillmentWebServiceSoapClient
Inherits System.ServiceModel.ClientBase(Of TestService.EFulfillmentWebServiceSoap)
Implements TestService.EFulfillmentWebServiceSoap
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
<System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)> _
Function TestService_EFulfillmentWebServiceSoap_FulfillPolicyXML(ByVal request As TestService.FulfillPolicyXMLRequest) As TestService.FulfillPolicyXMLResponse Implements TestService.EFulfillmentWebServiceSoap.FulfillPolicyXML
Return MyBase.Channel.FulfillPolicyXML(request)
End Function
Public Function FulfillPolicyXML(ByVal fulfillmentXML As String) As String
Dim inValue As TestService.FulfillPolicyXMLRequest = New TestService.FulfillPolicyXMLRequest
inValue.Body = New TestService.FulfillPolicyXMLRequestBody
inValue.Body.fulfillmentXML = fulfillmentXML
Dim retVal As TestService.FulfillPolicyXMLResponse = CType(Me,TestService.EFulfillmentWebServiceSoap).FulfillPolicyXML(inValue)
Return retVal.Body.FulfillPolicyXMLResult
End Function
<System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)> _
Function TestService_EFulfillmentWebServiceSoap_OperationStatusXML(ByVal request As TestService.OperationStatusXMLRequest) As TestService.OperationStatusXMLResponse Implements TestService.EFulfillmentWebServiceSoap.OperationStatusXML
Return MyBase.Channel.OperationStatusXML(request)
End Function
Public Function OperationStatusXML(ByVal status As String) As Boolean
Dim inValue As TestService.OperationStatusXMLRequest = New TestService.OperationStatusXMLRequest
inValue.Body = New TestService.OperationStatusXMLRequestBody
inValue.Body.status = status
Dim retVal As TestService.OperationStatusXMLResponse = CType(Me,TestService.EFulfillmentWebServiceSoap).OperationStatusXML(inValue)
Return retVal.Body.OperationStatusXMLResult
End Function
End Class
When I try to access that inside of my code (it's in a class library project), I can do things like "Dim x as New EFulfillmentWebServiceSoapClient", but it won't let me use access or even see any of the methods of that client, even though it can see the class and the methods are public.
I can do it when I put the code into an exe, but when it's a dll, it doesn't work. I need to have the webservice accessed as a dll which will be called from other applications.