使用 vb.net 向 webservice 请求肥皂客户端 [英] soap request client to webservice using vb.net
问题描述
我的问题类似于
我想调用一个网络服务,但是不像上面链接中显示的方式.我所做的是,使用 wsdl url 创建了一个服务引用(在具有按钮单击事件的 Windows 应用程序中)
I wanted to invoke a webservice, however not like the way shown in the link above.What I did was, created a service reference with the wsdl url(in a windows application with a button click event)
http://ipaddress:port/My/MyService?wsdl
已经创建了一个客户端对象
have created a client object
Dim objProxy As MyClient = New MyClient()
我使用以下方法填充了 objrequest 和 objreqheader,(分配字符串值而不是 xml)
I have populated the objrequest and objreqheader using the below methods, (assigning string values and not xml)
objreqheader.id = "abcd"
最后下面一行调用服务
objresponsehead = objProxy.myoperation(objreqheader, objrequest, objresp)
参考vb,这是myoperation公共函数
From reference vb, this is the myoperation public function
Public Function myoperation(ByVal RequestHeader As AFA.RequestHeaderType, ByVal GetTransactionDetailsReq As AFA.GetTransactionDetailsReqType, <System.Runtime.InteropServices.OutAttribute()> ByRef GetTransactionDetailsResp As AFA.GetTransactionDetailsRespType) As AFA.ResponseHeaderType
Dim inValue As AFA.getTransactionDetailsRequest = New AFA.getTransactionDetailsRequest()
inValue.RequestHeader = RequestHeader
inValue.GetTransactionDetailsReq = GetTransactionDetailsReq
Dim retVal As AFA.getTransactionDetailsResponse = CType(Me,AFA.myservice).getTransactionDetails(inValue)
GetTransactionDetailsResp = retVal.GetTransactionDetailsResp
Return retVal.ResponseHeader
End Function
问题是我的 objresp 是空的.没有生成异常,objresponsehead 填充为abcd".不调用该服务.我不确定如何从应用程序配置文件中获取跟踪文件来调试问题.我记得,当我第一次使用它时,出现错误没有可以接受消息的端点侦听",但是现在没有错误.
The problem is my objresp is coming as empty. There is no exception generated, objresponsehead is populated as "abcd". The service is not invoked. I am not sure how to get the trace file from the app config file, to debug the issue. I remember, when i used this for the first time, got an error "no endpoint listening that could accept the message", however there is no error now.
我在应用程序配置文件中添加了以下内容以获取跟踪以查看发生了什么.但是没有看到生成任何跟踪文件(trace.log).
I added the below in the app config file to get the trace to see what is going on. But did not see any trace file(trace.log) generated.
<system.diagnostics>
<trace autoflush="true">
<listeners>
<add type="System.Diagnostics.TextWriterTraceListener" name="TextWriter" initializeData="trace.log" />
</listeners>
</trace>
</system.diagnostics>
我检查了 objProxy 的属性,它具有基本的 http 绑定作为属性.任何人都像这样调用了服务?在我填充请求字段后,soapui 的响应很好.
I checked the property of objProxy, it is having basic http binding as the property. Anyone invoked the service like this? From soapui, the response is fine, after i populate the request fields.
如何启用跟踪以查看请求的内容以及问题出在哪里.
How can i enable the trace to see what is the request going and where is the problem.
推荐答案
参见 Message记录:
<system.diagnostics>
<sources>
<source name="System.ServiceModel.MessageLogging">
<listeners>
<add name="messages"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\logs\messages.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging
logEntireMessage="true"
logMalformedMessages="false"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="false"
maxMessagesToLog="3000"
maxSizeOfMessageToLog="2000"/>
</diagnostics>
</system.serviceModel>
这篇关于使用 vb.net 向 webservice 请求肥皂客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!