如何通过PL SQL调用soap Web服务

时间:2014-06-16 15:12:35

标签: web-services soap plsql

这是我的网络服务链接

http://83.143.26.34/MMWebService/MMWebSrv.asmx?WSDL

我想通过PLSQL调用SendTextMessage方法。任何人都可以帮助我吗?

这是我用过的plsql代码。我得到了例外的时间。但是通过SOAP-UI很好。

declare
  l_request     soap_api.t_request;
  l_response    soap_api.t_response;
  l_return      VARCHAR2(32767);
  l_url         VARCHAR2(32767);
  l_namespace   VARCHAR2(32767);
  l_method      VARCHAR2(32767);
  l_soap_action VARCHAR2(32767);
  l_result_name VARCHAR2(32767);

BEGIN

  l_url         := 'http://83.143.26.34:4000/MMWebService/MMWebSrv.asmx';
  l_namespace   := 'xmlns:ser="urn:MMWebSrvService"';
  l_method      := 'SendTextMessage';
  l_soap_action := l_url || '/' || l_method;
  l_result_name := 'return';
  l_request     :=  soap_api.new_request(p_method    => l_method,
                                             p_namespace => l_namespace);
  soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strUsername',
                              p_type    => 'xsd:string',
                              p_value   => 'BIHL');
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strPassword',
                              p_type    => 'xsd:string',
                              p_value   => 'monday@123');
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strFrom',
                              p_type    => 'xsd:string',
                              p_value   => 'UserFrom');
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strTo',
                              p_type    => 'xsd:string',
                              p_value   => '74747574');
    soap_api.add_parameter(p_request => l_request,
                               p_name    => 'strMessage',
                               p_type    => 'xsd:string',
                               p_value   => 'UserMsg');
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strSubject',
                              p_type    => 'xsd:string',
                              p_value   => 'UserSub');
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strService',
                              p_type    => 'xsd:string',
                              p_value   => 'UserSrv');
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'nOptions',
                              p_type    => 'xsd:int',
                              p_value   => 10);
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strTimeToSend',
                              p_type    => 'xsd:string',
                              p_value   => sysdate);
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strReference',
                              p_type    => 'xsd:string',
                              p_value   => 'UserRef');
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strBillText',
                              p_type    => 'xsd:string',
                              p_value   => 'UserTxt');
   soap_api.add_parameter(p_request => l_request,
                              p_name    => 'strSessionID',
                              p_type    => 'xsd:string',
                              p_value   => 'UserSID');

  l_response :=  soap_api.invoke(p_request  => l_request,
                                     p_url      => l_url,
                                     p_action   => l_soap_action);

  l_return := soap_api.get_return_value(p_response  => l_response,
                                             p_name      => l_result_name,
                                             p_namespace => NULL);

EXCEPTION
  WHEN OTHERS THEN
    pkg_pub_scd_ci.p_log_error('webservice to send a message' || ' -- ' ||
                               sqlerrm ||
                               dbms_utility.format_error_backtrace);
end;

0 个答案:

没有答案